Part B. Find the Bug

The original code is displayed below.

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 supposed to display the real part of the complex exponential, which is a sine wave. This code actually produces a distorted sine, since the step size, Ts, is not sufficiently small to get enough data points to produce a smooth curve.

Solution

In order to correct this, one simply must adjust the step size, Ts, to get smaller readings, producing a smoother curve. The smaller the step size one chooses, the smoother the output curve will be. A step size of Ts/100 or even Ts/1000 or Ts/10000 will produce a sufficiently smooth sine wave. The new code is displayed below.

F0 =13;

T0 =1/F0;

Ts = 0.07/10000

t  = 0:Ts:13*T0;

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

plot(t,x)

Alumni Liaison

Abstract algebra continues the conceptual developments of linear algebra, on an even grander scale.

Dr. Paul Garrett