Answer To: Unknown XXXXXXXXXXEGR324L: Linear Systems and Signals Lab XXXXXXXXXXLab 3: Fourier Series Objective...
Kshitij answered on Sep 25 2021
reurgentsignal (1)/ExperimentQ.m
% ( 1A) Plot imag( sq_wave(19)) and imag( sq_wave(39 )) using function trainplot developed in part (0A)
% (2A) Using function trainplot, plot real and imaginary part of ak
% obtained with saw_wave(19). Use Matlab function subplot so that then two plots can be shown in the same graphic window.
n=[19 39];
for ii=1:numel(n)
ox_sq=-n(ii);
vx_sq=imag(sq_wave(n(ii)));
figure(),
trainplot(ox_sq,vx_sq)
xlabel('n');
str=['image fourier series of square wave for n= ',num2str(n(ii))];
title(str);
end
%%
% (1B) Using functions sq_wave and fs_approx, compute and plot
% approximations x5( t), x19( t), x79( t) for at least one period, say for tmin = -0.5? to tmax = 1.8?.
tmin=-0.5*pi;
tmax=1.8*pi;
w0=1;
N=[5 19 79];
for kk=1:numel(N)
a=sq_wave(N(kk));
[x,t]=fs_approx(a,w0,tmin,tmax,N(kk));
figure(),
plot(t,x,'b','LineWidth',2); grid on;
xlabel('Time (sec)')
str1=['The fourier series figure of square wave with n= ',num2str(N(kk))];
title(str1);
end
%%
% We note that as N increase the fourier seires approximation is almost
% perfect
% (2A) Using function trainplot, plot real and imaginary part of ak
% obtained with saw_wave(19). Use Matlab function subplot so that then two plots can be shown in the same graphic window.
ak=saw_wave(19);
figure(),
subplot(1,2,1),trainplot(-19,real(ak));
title('The real part of saw wave ');
subplot(1,2,2),trainplot(-19,imag(ak));
title('The imaginary part of saw wave');
%%
% (2B) Using functions saw_wave and fs_approx, plot x5(t), x20(t) and
% x80(t) for at least one period. Note that for better presentation,
% you may want to compute and plot the approximations for tmin = -0.2 to tmax = 1.2.
tmins=-0.2;
tmaxs=1.2;
ws0=2*pi;
Ns=[5 20 80];
for k=1:numel(Ns)
as=saw_wave(Ns(k));
[xs,ts]=fs_approx(as,ws0,tmins,tmaxs,Ns(k));
figure(),
plot(ts,xs,'b','LineWidth',2); grid on;
xlabel('Time (sec)')
str2=['The fourier series figure of saw wave with n= ',num2str(Ns(k))];
title(str2);
end
%%
% (3A) Compute and plot real( half_rect( 20)) using function trainplot.
% What can you say about the imaginary part of the Fourier series, and why?
ah=half_rect(20);
figure(),
trainplot(-20,real(ah));
title('The real part of half wave ');
%%
% (3B) Using functions half_rect and fs_approx, compute and plot x5(t), x10(t), x20(t) and
% x40(t) for at least one period, say from fmin = -12 (ms) to fmax = 12 (ms).
tminh=-12;
tmaxh=12;
wh0=pi/10;
Nh=[5 10 20];
for kh=1:numel(Nh)
...