Plotting the Fourier series for the function f=pi+x
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Charith Silva
il 21 Lug 2019
Commentato: Star Strider
il 23 Lug 2019
I was trying to plot the Fourier series representation of the graph of (which should be a straight line).
And the Fourier series representation is given as:
This is the code that I'm using: ()
x=-pi:0.01:pi;
y=x+pi
Fr=0;
for i=1:100
an=((-1)*(i+1)*sin(i*x))/i;
Fr=Fr+2*an;
end
Fr=Fr+pi;
plot(x,Fr)
But I'm getting a graph no where close to a straight line.
A help would be highly appreciated
2 Commenti
Walter Roberson
il 21 Lug 2019
The original is a straight line. The fourier transform of it is a delta function
https://dsp.stackexchange.com/questions/36552/fourier-transform-of-a-tilted-line-function
Risposta accettata
Star Strider
il 21 Lug 2019
You forgot to raise (-1) to a power. (You multiplied it instead.)
Try this:
an=((-1).^(i+1)*sin(i*x))/i;
Also, more terms produces a smoother plot.
To check the result, I did it without a loop:
n = 1:1E+3;
F = pi + 2*sum(sin(n(:)*x).*(-1).^(n(:)+1)./n(:));
figure
plot(x, F)
producing essentially the same plot.
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Frequency Transformations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!