I completed most of the answers but am not sure I did them right. I especially d
ID: 2079549 • Letter: I
Question
I completed most of the answers but am not sure I did them right. I especially don't know how to do III
I have this matlab code, and need help with part 1(a): I, III, and part 1(c) please.
clf; clear; %Clear all workspace
T0 = 4.0; %The period of x(t)
W0 = 2.0*pi/T0; %The fundamental frequency
%Let us evaluate for N time points every
%T seconds over two periods of x(t)
T = 0.001; N = 8000;
%We will get 8000 points over the range t=0.0 to t=(N-1)T secs
%Let the time points be N elements of a vector time, starting at
%time(1)=0.0, incrementing by T, until the last element time(N)
time = 0.0:T:(N-1)*T;
%Let us truncate the series for from -K to +K
%and try K=5
K = 100;
%Using a MATLAB function to set to zero the N elements
%of a vector x
x = zeros(1,N);
%For each pass through the following for-loop a term in the Fourier
%series for is evaluated for all the elements (time
% points) in the vector time
for k = -K: 1: K;
W=k*W0;
if k == 0;
Xk = -2.0;%Gives the average value of x(t)
else
C=1.0/W^2;
Xk = 1i*(2.0*C*(sin(2.0*W)-2.0*sin(W)));
%i is the MATLAB symbol for the square root of (-1)
end;
x = x + Xk*exp(1i*W*time);
end;
plot(time,real(x));
grid;
xlabel('time-secs'); ylabel('volts');
title('Fourier series using a finite number of terms');
1(a)
(I) Explain the purpose of the program for-loop, and thoroughly explain the activity of the program line given by: x = x + etc.
(III) Add statements to the program to calculate and plot the magnitude spectrum of the signal versus frequency expressed in Hz. Use a MATLAB stem type plot for this. The frequency range must be from Hz to Hz. Print the program.
1(c)Will a measure of performance like the number ^2 given by ^2= (integral lower bound 0, upper bound T naught) of e^2 (t) dt ever become zero if K approaches infinity? Explain your answer.
Explanation / Answer
clf; clear; %Clear all workspace
T0 = 4.0; %The period of x(t)
W0 = 2.0*pi/T0; %The fundamental frequency
%Let us evaluate for N time points every
%T seconds over two periods of x(t)
T = 0.001; N = 8000;
%We will get 8000 points over the range t=0.0 to t=(N-1)T secs
%Let the time points be N elements of a vector time, starting at
%time(1)=0.0, incrementing by T, until the last element time(N)
time = 0.0:T:(N-1)*T;
%Let us truncate the series for from -K to +K
%and try K=5
K = 100;
%Using a MATLAB function to set to zero the N elements
%of a vector x
x = zeros(1,N);
%For each pass through the following for-loop a term in the Fourier
%series for is evaluated for all the elements (time
% points) in the vector time
for k = -K: 1: K;
W=k*W0;
if k == 0;
Xk = -2.0;%Gives the average value of x(t)
else
C=1.0/W^2;
Xk = 1i*(2.0*C*(sin(2.0*W)-2.0*sin(W)));
%i is the MATLAB symbol for the square root of (-1)
end;
x = x + Xk*exp(1i*W*time);
end;
plot(time,real(x));
grid;
xlabel('time-secs'); ylabel('volts');
title('Fourier series using a finite number of terms');
f= @(t) exp(2*t);
to=input('value of to');
t=0:0.01:3;
q = integral(f(t),0,to);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.