Revision as of 05:42, 12 September 2008 by Ccadwall (Talk)

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

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett