(New page: == Original Code == The code that follows has a bug. <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>)
 
(Original Code)
 
Line 9: Line 9:
  
 
Ts = 0.07;
 
Ts = 0.07;
 +
 +
t  = 0:Ts:13*T0;
 +
 +
x = real(exp(j*(2*pi*F0*t-pi/2)));
 +
 +
plot(t,x)
 +
</pre>
 +
 +
== Problem with Original Code ==
 +
 +
The problem with the original code is that it cannot plot 13 cycles of the 13Hz sinusoid because the Time Step (Ts) value is much too large since the value of 1 cycle is .0769. Therefore the Time Step must be greatly reduced. Dividing the Time Step by 130 gives us 13 cycles on the plot.
 +
 +
== Code with Bug Fixed ==
 +
 +
<pre>
 +
F0 =13;
 +
 +
T0 =1/F0;
 +
 +
Ts = 0.07/130;
  
 
t  = 0:Ts:13*T0;  
 
t  = 0:Ts:13*T0;  

Latest revision as of 09:09, 9 September 2008

Original Code

The code that follows has a bug.

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)

Problem with Original Code

The problem with the original code is that it cannot plot 13 cycles of the 13Hz sinusoid because the Time Step (Ts) value is much too large since the value of 1 cycle is .0769. Therefore the Time Step must be greatly reduced. Dividing the Time Step by 130 gives us 13 cycles on the plot.

Code with Bug Fixed

F0 =13; 

T0 =1/F0; 

Ts = 0.07/130;

t  = 0:Ts:13*T0; 

x = real(exp(j*(2*pi*F0*t-pi/2)));

plot(t,x)

Alumni Liaison

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin