Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

help me fix the code in which data extracted from a sound file are manipulated

Asked by Passband Modulation on 5 Oct 2012

a sound file with content consisting of 65120 rows of item as following shows

file source: http://www.2shared.com/document/LCmLelLW/message.html

where r[k] corresponds to message. say for example :

r[k] corresponds to the floating point number in first row of the file for k=0.

r[k] corresponds to the floating point number in second row of the file for k=1.

r[k] corresponds to the floating point number in third row of the file for k=2. and so on.

finally, r[k] corresponds to the floating point number in last row of the file for k=65119.

i want to plot s[k] using the following equation s[k]=r[k]-56.97cos(3.6k)-31.98sin(3.6k)

for k=0:length(message)-1

i tried, but again failed.

 load message.txt
 N=65120;                         
 k=0:N-1;                         
 s = message - 56.97*cosd(3.6*k)-31.98*sind(3.6*k);              
 s
 k=0:N-1;                       
 plot(k,s)                       
 xlabel('k');    

could anyone help to fix? thx!

0 Comments

Passband  Modulation

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 5 Oct 2012
Accepted answer
 load message.txt
 N=65120;                         
 k=0:N-1;                         
 s = message - 56.97*cosd(3.6*k.')-31.98*sind(3.6*k.');        %changed      
 s
 %k=0:N-1;        %no need to recalculate it               
 plot(k,s)                       
 xlabel('k');    

1 Comment

Passband Modulation on 6 Oct 2012

thank you, it finally works!

Walter Roberson

Contact us