All pastes #474899 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-07 02:03 UTC
rendered paste body
//part 4: Pick a telephone key of your choice.
//generate and plot a quarter second (.25sec) DTMF
//signal corosponding to that key. Use a sampling
//period T = 1/8000 sec. Use A1=A2=1
//5 key: 770 Hz and 1336 Hz
time2 = 0:1/8000:.25;
key5 = sin(2*%pi*770*time2)+sin(2*%pi*1336*time2);
plot(time2,key5);
title('part 4, 5 key');
xlabel('time, seconds');
ylabel('Amplitude');
//part 5: plot the magnitude spectrum of part 4 as
//learned in part 1
//omega2 = [-pi/(1/8000):(2*pi)/(length(time2)*(1/8000)):(-pi/(1/8000))+((length(time2)-1)*2*pi)/(length(time2)*(1/8000))];
Key5mag = abs(fftshift(fft(key5)));
plot([500:1500],Key5mag(500:1500));
title('Part 5');
xlabel('frequency Hz');
ylabel('Magnitude');
//Key5mag = psd(key5,'fs',8000);
//plot(Key5mag);
//sound(key5,8000);
tones1 = sin(2*%pi*697*time2)+sin(2*%pi*1477*time2);
tones2 = sin(2*%pi*770*time2)+sin(2*%pi*1336*time2);
//7 key
tones3 = sin(2*%pi*852*time2)+sin(2*%pi*1209*time2);
//pause
pauses = zeros(1,800);
tones = [tones1 pauses tones2 pauses tones3];
plot([0:1/8000:(length(tones)-1)/8000],tones);
title('Part 6, 3, 5, and 7 keys');
xlabel('time, seconds');
ylabel('Amplitude');
//part 7
sound(tones,8000);