How would you write this in MATLAB & Simulink? Desperately need help... Plotting
ID: 2988757 • Letter: H
Question
How would you write this in MATLAB & Simulink? Desperately need help...
Plotting Fourier series Fig. 1 Waveform of f(t) for Task 1 The Fourier coefficients for f(t) in Fig. 1 are found as follows. The trigonometric Fourier series is 1) Plot f(t) for 3 different values of n where n is number of harmonics in the series (n = 2, 5,10). Show the three figures and observe how the number of harmonics impacts the waveform of 2) Continue to plot f(t) using a larger number of harmonics and answer the question: How many handonics do you indude in order to obtain the original f(t)? (i.e. v/hen your waveform of f(t) looks like the waveform in Fig. 1, approximately).Explanation / Answer
Here is the MATLAB code : ( also plots for case of n = 100 )
t = 0:0.01:20;
f_2 = 1/4;
f_5 = 1/4;
f_10 = 1/4;
f_100 = 1/4;
% With n = 2
for i=1:2
f_2 = f_2 + (2 / (i*pi))*(2*sin(i*pi/4) - sin(i*pi/2))*cos(i*pi*t/4);
end
% With n = 5
for i=1:5
f_5 = f_5 + (2 / (i*pi))*(2*sin(i*pi/4) - sin(i*pi/2))*cos(i*pi*t/4);
end
% With n = 10
for i=1:10
f_10 = f_10 + (2 / (i*pi))*(2*sin(i*pi/4) - sin(i*pi/2))*cos(i*pi*t/4);
end
% With n = 100
for i=1:100
f_100 = f_100 + (2 / (i*pi))*(2*sin(i*pi/4) - sin(i*pi/2))*cos(i*pi*t/4);
end
plot(t,f_2,t,f_5,t,f_10,t,f_100)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.