Plotting Fourier Series Function

2 visualizzazioni (ultimi 30 giorni)
random1072
random1072 il 28 Set 2020
Risposto: Nikhil Sonavane il 1 Ott 2020
Hello I am trying to plot a Fourier Series for t = 0 to 5T. I have attached my code as well as my current plot output (which is obviously wrong). Not really sure where to go from here any help would be great.
Pressure = 95 + 9 - 1.1 sin cos 13.7t + 5 13.7t - 3 .3 sin .5 cos 27.3t + 7 sin 41t + 1 sin 55t + 0.6 27.3t - 2.6 cos 41t - 1.6 cos 55t - 1.7 = 95 + 9.1 + 2.2 sin sin (13.7t-7° (55t-6l°) ) + 6 .4 + 1.8 sin (27.3t-34°) + 7.5 sin (41t-21°) sin (68.5t-71°)
A_0 = 95;
A_1 = 9.1;
w_1 = 13.7;
theta_1 = -7;
A_2 = 6.4;
w_2 = 27.3;
theta_2 = -34;
A_3 = 7.5;
w_3 = 41;
theta_3 = -21;
A_4 = 2.2;
w_4 = 55;
theta_4 = -61;
A_5 = 1.8;
w_5 = 68.5;
theta_5 = -71;
t = [0;5*.459;5*.230;5*.153;5*.114;5*.092];
y = A_0 + A_1*sin(w_1*t+theta_1) + A_2*sin(2*w_2*t+theta_2)...
+ A_3*sin(3*w_3*t+theta_3) + A_4*sin(4*w_4*t+theta_4)...
+ A_5*sin(5*w_5*t + theta_5);
plot (t,y)
*Current output below
*What Output is supposed to look like

Risposte (1)

Nikhil Sonavane
Nikhil Sonavane il 1 Ott 2020
The error which I could notice is you are plotting y only at 5 points that is at 5 values of t.If you increase the number of points between 0 and 5T, you may get the desired output. I tried out the following and it worked for me-
t = [0;5*.459;5*.230;5*.153;5*.114;5*.092]; %Remove this from the code and replace it with the next line
t=linspace(0,5*0.092,1000); % Now t has 1000 linearly spaced values between 0 and 5*0.092
Here, 1000 is a value which I just randomly added. You can refer to the Sampling Theorem for more understanding.

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by