PART B: Bugged Code

The bugged code:


F0 =13;
T0 =1/F0;
Ts = 0.007;
t  = 0:Ts:13*T0;
x = real(exp(j*(2*pi*F0*t-pi/2)));
plot(t,x)

Outputs:

Ccadwall-buggedwave ECE301Fall2008mboutin.jpg


From the graph it appears that the frequency is a little less than one but the problem statement and the function indicates its a 13Hz sinusoid. The samples are not frequent enough and go beyond one period. To fix this code Ts must be decreased to a reasonably small value to improve the accuracy of the graph.

Fixed code and output:


F0 =13;
T0 =1/F0;
Ts = 0.00007;
t  = 0:Ts:13*T0;
x = real(exp(j*(2*pi*F0*t-pi/2)));
plot(t,x)

Ccadwall-buggedwavefixed ECE301Fall2008mboutin.jpg

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood