Effacer les filtres
Effacer les filtres

Using Fourier Series write a MATLAB function to synthesize the wave-form in problem (2-19), Assume A = 4mV. Your function should take n ( # of harmonics ) and produce a plot

11 vues (au cours des 30 derniers jours)
I am trying to plot the fourier series for the graph
I was told to assume that A=4mV and that the A value occurs at time 4mS. I was able to figure out the fourier equation in matlab should be
syms t
T=0.01
w=200*pi;
An1=(2/T)*((int(t*cos(w*N*t),t,0,0.004)));
An2=(2/T)*((int((-4*t+0.020)*cos(w*N*t),t,0.004,0.005)));
An3=(2/T)*((int((-1*t+0.005)*cos(w*N*t),t,0.005,0.009)));
An4=(2/T)*((int((4*t-0.036)*cos(w*N*t),t,0.009,0.01)));
AnT=An1+An2+An3+An4;
Bn1=(2/T)*((int(t*sin(w*N*t),t,0,0.004)));
Bn2=(2/T)*((int((-4*t+0.020)*sin(w*N*t),t,0.004,0.005)));
Bn3=(2/T)*((int((-1*t+0.005)*sin(w*N*t),t,0.005,0.009)));
Bn4=(2/T)*((int((4*t-0.036)*sin(w*N*t),t,0.009,0.01)));
BnT=Bn1+Bn2+Bn3+Bn4;
V(t)=(AnT*cos(w*N*t))+(BnT*sin(w*N*t));
But I have no clue how to correctly plot this information to correctly get the fourier
  1 commentaire
William Rose
William Rose le 11 Sep 2023
@Evan, read the help on plot(...). And consider stem(...) which is not bad for plotting the Fourier coefficients.
General idea could be
subplot(211); stem(frequencies, magnitudes)
subplot(212); stem(frequencies, phase angles)
where you put in suitable substitues for frequencies, magnitudes, phases. Look up the details and optinal parameters to make your plots look nice.

Connectez-vous pour commenter.

Réponses (1)

Paul
Paul le 12 Sep 2023
Hi Evan
First, check your code that defines one period of v(t). It''s probably easier to define v(t) using piecewise
syms t
T=0.01;
w=200*pi;
v(t) = piecewise( ...
0<=t<0.004,t, ...
0.004<t<=0.005,-4*t+0.020, ...
0.005<t<=0.009,-1*t+0.005, ...
0.009<t<=.01, 4*t-0.036,0);
Here's the plot, from which it's apparent the fourth segment is not correct.
figure
fplot(v(t),[0 T]),grid
If you choose to define one period of v(t) using piecewise, then you can use that expression to comput expressions for An and Bn in terms of N.
Once you have those expressions you can use subs to compute An and Bn at integer values of N and compute the Fourier series summation from those results.
If you try all of this and get stuck, feel free to post back with updated code and explain where the sticking point is.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by