Need help about function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have written this function for piano
function tone=note(keynum,dur) % %This function produces sinusoidal waveform corresponding to given piano %key number %tone=output sinusoidal waveform %keynum= The piano keyboard number %dur= The duration in seconds of output note fs=8000; tt=0:(1/fs):dur; freq = 440 (2^((keynum-49)/12)); tone=sin(2*pi*freq(0:0.000125:1));
Now If i use soundsc(tone,fs) command in the code of this function then every thing is ok but the book says
"You can play the output of this function using the soundsc() function in Matlab. DO NOTcall the sound fucntion within the M-file.
Plz help me how to go about this. when i write note(12,3) in matlab it is ok but when i write soundsc(tone,fs) in matlab after this it gives error
0 Kommentare
Akzeptierte Antwort
Wayne King
am 19 Sep. 2011
How are you calling the function, note(), at the command line?
You should call it as:
tone = note(12,3);
Then there will be a variable in your workspace named tone and you can execute
soundsc(tone,fs)
If you call it as
note(12,3)
then your output appears as ans
Wayne
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!