Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a matlab script used to play a sound i have a problem with the second to

ID: 3782972 • Letter: T

Question

This is a matlab script used to play a sound i have a problem with the second to last line where it says " insert the note" i dont know how to write it in the script so i can play the sound .

% --------------play_lamb.m-------------- %

mary.keys = [44 42 40 42 44 44 44 42 42 42 44 47 47];

% NOTES: C D E F G % Key #40 is middle-C mary.durations = 0.25 * ones(1,length(mary.keys));

fs = 8000; % 11025 Hz also works xx = zeros(1, sum(mary.durations)*fs + length(mary.keys));

n1 = 1; forkk = 1:length(mary.keys) keynum = mary.keys(kk);

tone = % <------- Fill in this line n2 = n1 + length(tone) - 1; xx(n1:n2) = xx(n1:n2) + tone;%<------- Insert the note

n1 = n2 + 1;

end soundsc(xx, fs)

Explanation / Answer

mary.keys = [44 42 40 42 44 44 44 42 42 42 44 47 47];
% NOTES: C D E F G % Key #40 is middle-C mary.durations = 0.25 * ones(1,length(mary.keys));
fs = 8000; % 11025 Hz also works xx = zeros(1, sum(mary.durations)*fs + length(mary.keys));
n1 = 1;
Ts=1/fs;
tone=[0:Ts:1];
fork k = 1:length(mary.keys) keynum = mary.keys(kk);
   n2 = n1 + length(tone) - 1;
   xx(n1:n2) = xx(n1:n2) + tone;
   n1 = n2 + 1;
end
soundsc(xx, fs)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote