(New page: ==Problem== The bug occurs because the sampling rate is too small. The period of the sinusoidal signal given is 1/13 = 0.0769 and the sampling period set is 0.07. It is clear to see that ...) |
(→Solution) |
||
Line 18: | Line 18: | ||
plot(t,x) | plot(t,x) | ||
+ | |||
+ | [[Image: debugged_ECE301Fall2008mboutin.jpg]] |
Latest revision as of 13:59, 11 September 2008
Problem
The bug occurs because the sampling rate is too small. The period of the sinusoidal signal given is 1/13 = 0.0769 and the sampling period set is 0.07. It is clear to see that the program only samples once per period printing only one cycle. Therefore, it is necessary to increase the sampling frequency by decreasing the sampling period Ts.
Solution
Here is the debugged MATLAB code
F0 =13;
T0 =1/F0;
Ts = 0.00001;
t = 0:Ts:13*T0;
x = real(exp(j*(2*pi*F0*t-pi/2)));
plot(t,x)