(New page: ==Homework 2 part B. Finding the Bug== == 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> <br>The previous code ha...)
 
 
Line 11: Line 11:
 
<br>The previous code has a bug that needs to be diagnosed
 
<br>The previous code has a bug that needs to be diagnosed
 
<br>When the program is ran, the plot is extremely rough and ugly.
 
<br>When the program is ran, the plot is extremely rough and ugly.
<br>By changing Tz to .001, the plot becomes smooth and desirable.
+
<br>The problem is that the sample rate is too large
 +
<br>By changing Ts to .001, the plot becomes smooth and desirable.
 +
== Correct Code ==
 +
<pre>
 +
F0 =13;
 +
T0 =1/F0;
 +
Ts = 0.001;
 +
t  = 0:Ts:13*T0;
 +
x = real(exp(j*(2*pi*F0*t-pi/2)));
 +
plot(t,x)
 +
</pre>

Latest revision as of 11:14, 11 September 2008

Homework 2 part B. Finding the Bug

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)


The previous code has a bug that needs to be diagnosed
When the program is ran, the plot is extremely rough and ugly.
The problem is that the sample rate is too large
By changing Ts to .001, the plot becomes smooth and desirable.

Correct Code

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

Alumni Liaison

EISL lab graduate

Mu Qiao