(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<pre>
 
The following  MATLAB code doesn't work properly since the step value, Ts, is too big.
 
The following  MATLAB code doesn't work properly since the step value, Ts, is too big.
  
 
'''Code Containing the "Bug"'''
 
'''Code Containing the "Bug"'''
<break>
+
 
 
F0 =13;  
 
F0 =13;  
 
T0 =1/F0;  
 
T0 =1/F0;  
Line 10: Line 11:
 
plot(t,x)
 
plot(t,x)
  
However, by reducing the step size the matlab commands will print all 13 cycles of the 13Hz sinusoid. I chose to reduce the value by multiplying it by <math>10^-2</math>, which leaves us with Ts = 0.0007. The proper working code is shown below:
+
However, by reducing the step size, the MATLAB routine will print all 13 cycles of the 13Hz sinusoid.
 +
I chose to reduce the value by multiplying it by <math>10^-2</math>, which leaves us with Ts = 0.0007.
 +
The proper working code is shown below:
  
 
'''Code After Reducing Ts Step Value'''
 
'''Code After Reducing Ts Step Value'''
<break>
+
 
 
F0 =13;  
 
F0 =13;  
 
T0 =1/F0;  
 
T0 =1/F0;  
Line 20: Line 23:
 
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>

Latest revision as of 17:43, 10 September 2008

The following  MATLAB code doesn't work properly since the step value, Ts, is too big.

'''Code Containing the "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)

However, by reducing the step size, the MATLAB routine will print all 13 cycles of the 13Hz sinusoid.
I chose to reduce the value by multiplying it by <math>10^-2</math>, which leaves us with Ts = 0.0007.
The proper working code is shown below:

'''Code After Reducing Ts Step Value'''

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

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn