Please Solve this Question anyway either by using MATLAB or any other way .....
QUESTION :
Generate a square wave with peak as last 2 digits of your roll number.
Find the overshoot value for this square wave.
How many harmonics are required to generate this square wave with 9% overshoot.
Find the overshoot when 101 harmonics are used.
Find the overshoot when 401 harmonics are used.
Exploit the effect of odd harmonics in generating a square wave.
Draw necessary conclusions about Gibbs phenomenon and its effects on Fourier series.
Hint : Use Gibbs Phenomenon
When 101 harmonics are used:
MATLAB:
clc;
clear all;
close all;
T=4;t=0:0.01:T;A=10;
x=A.*(t>=0 &t<=2)
%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=50
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T;n=-N:1:N;
%output xN(t)
k=0;
w0=2*pi/T;
for t=0:0.01:T
k=k+1;
xN(k)=sum(a.*(exp(j*n*w0*t)));
end
t=0:0.01:T;
plot(t,xN,'r',t,x,'b')
title('Fourier approx of squre wave for N=101')
xlabel('t')
ylabel('xN(t)')
stepinfo(real (xN))
Command window:
RiseTime: 0
SettlingTime: 400.9515
SettlingMin: -0.8645
SettlingMax: 5.0000
Overshoot: 117.2936
Undershoot: 17.2901
Peak: 10.8647
PeakTime: 198
% overshoot:
overshoot -100%=117.29-100%=17.29%
___________________________________________________________________________
When 401 harmonics are used:
MATLAB:
clc;
clear all;
close all;
T=4;t=0:0.01:T;A=10;
x=A.*(t>=0 &t<=2)
%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=200
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T;n=-N:1:N;
%output xN(t)
k=0;
w0=2*pi/T;
for t=0:0.01:T
k=k+1;
xN(k)=sum(a.*(exp(j*n*w0*t)));
end
t=0:0.01:T;
plot(t,xN,'r',t,x,'b')
title('Fourier approx of squre wave for N=401')
xlabel('t')
ylabel('xN(t)')
stepinfo(real (xN))
Command window:
RiseTime: 0
SettlingTime: 400.9799
SettlingMin: -0.0250
SettlingMax: 5.0000
Overshoot: 100.5000
Undershoot: 0.5000
Peak: 10.0250
PeakTime: 201
% overshoot:
Overshoot -100%=100.5-100%=0.5%
_________________________________________________________________________
To achieve 9% overshoot
clc;
clear all;
close all;
T=4;t=0:0.01:T;A=10;
x=A.*(t>=0 &t<=2)
%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;
k=0;
for n=-180:1:181
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T;n=-180:1:181
%output xN(t)
k=0;
w0=2*pi/T;
for t=0:0.01:T
k=k+1;
xN(k)=sum(a.*(exp(j*n*w0*t)));
end
t=0:0.01:T;
plot(t,xN,'r',t,x,'b')
title('Fourier approx of squre wave for N=362')
xlabel('t')
ylabel('xN(t)')
stepinfo(real (xN))
Command window:
RiseTime: 2.8422e-14
SettlingTime: 400.9781
SettlingMin: -0.4610
SettlingMax: 5.0000
Overshoot: 109.2182
Undershoot: 9.2199
Peak: 10.4609
PeakTime: 200
% overshoot:
Overshoot -100%=109.21-100%=9.21%
Observation
For 362 harmonics , the overshoot in % is 9.21%
For 401 harmonics , the overshoot in % is 0.5%
For 101 harmonics , the overshoot in % is 17.29%
Please Solve this Question anyway either by using MATLAB or any other way ..... QUESTION : Generate a square wave with p...
In MATLAB, generate a square wave of period 1s and length of 8s, sampled at 1024HZ. The maximum value of the wave is 1 and the minimum value is -1. Take the fft of this data. Show both plots. The fft should represent Fourier series representation of the wave in lecture, comment on this aspect. Comment on the difference in FFT when I sample for 8.01 sec instead of 8 sec.