quiz9_solution

# quiz9_solution - figure(1%plots sound wave amp vs time in...

This preview shows pages 1–2. Sign up to view the full content.

1 %KEYPAD - A script that loads tone.dat, an ascii file %with column 1 giving the sound wave amplitude, into a MATLAB array, %plots sound wave amplitude vs. time, takes the fft of the input data, %and plots power vs. frequency. Note the sampling frequency is 8192 samples %per sec and tone.dat has 4096 data points. %File written by S.C. Tegler. Last modified 3/31/11. %--------------------------------------------------- load tone.dat -ascii %load ascii file signal = tone(:,1); %create signal vector L = length(signal); %length of signal vector t = 0:(1/8192):(L-1)*(1/8192); %create time vector corresponding to %signal vector

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: figure(1); %plots sound wave amp vs. time in sec plot(t,signal); xlabel( 'Time (sec)' ); ylabel( 'Sound Wave Amplitude' ); title( 'Key Signal' ); %axis([0.25 0.26 -0.8 0.8]); Y = fft(signal); %fft of sound wave signal Y(1) = 0; %set first element of fft output to 0 Power = abs(Y).^2; %computes power of fft output dv = 8192/4096; %computes frequency interval v = 0:dv:8191; %creates frequency vector figure(2); %plots power spectrum upto Nyquist plot(v(1:L/2),Power(1:L/2)); %frequency xlabel( 'Frequency (Hz)' ); ylabel( 'Power' ); title( 'Frequencies are 776 and 1208 Hz = Key 4' ); 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

quiz9_solution - figure(1%plots sound wave amp vs time in...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online