(New page: This is the original code: <pre> F0 = 13; T0 = 1/F0; Ts = 0.07; t = 0:Ts:13*T0; x = real(exp(j*(2*pi*F0*t-pi/2))); plot(t,x) <\pre> This code is wrong because the sampling frequency, ...) |
|||
Line 9: | Line 9: | ||
x = real(exp(j*(2*pi*F0*t-pi/2))); | x = real(exp(j*(2*pi*F0*t-pi/2))); | ||
plot(t,x) | plot(t,x) | ||
− | < | + | </pre> |
This code is wrong because the sampling frequency, Ts, is to large to get an accurate recreation of the | This code is wrong because the sampling frequency, Ts, is to large to get an accurate recreation of the | ||
Line 21: | Line 21: | ||
x = real(exp(j*(2*pi*F0*t-pi/2))); | x = real(exp(j*(2*pi*F0*t-pi/2))); | ||
plot(t,x) | plot(t,x) | ||
− | < | + | </pre> |
Explain what the bug is, and modify the above code to fix this bug. Post your answer on a Rhea page. | Explain what the bug is, and modify the above code to fix this bug. Post your answer on a Rhea page. |
Revision as of 06:16, 10 September 2008
This is the original code:
F0 = 13; T0 = 1/F0; Ts = 0.07; t = 0:Ts:13*T0; x = real(exp(j*(2*pi*F0*t-pi/2))); plot(t,x)
This code is wrong because the sampling frequency, Ts, is to large to get an accurate recreation of the signal. By Nyquist's theorem, the descrete sampling frequency must be twice the continuous frequency in order to avoid unwanted artifacts. In other words Ts=.5*T0.
F0 = 13; T0 = 1/F0; Ts = .5*T0; t = 0:Ts:13*T0; x = real(exp(j*(2*pi*F0*t-pi/2))); plot(t,x)
Explain what the bug is, and modify the above code to fix this bug. Post your answer on a Rhea page.