(→Bugged Code) |
(→Bugged Code) |
||
Line 16: | Line 16: | ||
[[Image:Ccadwall-buggedwave_ECE301Fall2008mboutin.jpg]] | [[Image: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: | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | 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) | ||
+ | </pre> | ||
+ | |||
+ | [[Image:Ccadwall-buggedwavefixed_ECE301Fall2008mboutin.jpg]] |
Revision as of 05:42, 12 September 2008
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:
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)