n72.75
Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
- Joined
- Mar 21, 2008
- Messages
- 2,696
- Reaction score
- 1,353
- Points
- 128
- Location
- Saco, ME
- Website
- mwhume.space
- Preferred Pronouns
- he/him
So I've been banging my head against a little MATLAB problem for the past four hours or so.
I'm trying to compute the Fourier series of a triangle wave (for the purpose of none other then my own enjoyment). For some reason I can't seem to get the code right:
EDIT:
Never mind, I just set the iteration count higher and it works.
I'm trying to compute the Fourier series of a triangle wave (for the purpose of none other then my own enjoyment). For some reason I can't seem to get the code right:
Code:
clear;
clc;
format [COLOR="DarkOrchid"]long[/COLOR];
itteration_count = 50;
sum_count = 50;
peroid = 2*pi;
origin = 0;
t = origin:peroid/itteration_count:peroid;
f = 1:itteration_count+1;
[COLOR="Blue"]for[/COLOR] k = 0:itteration_count
sum = 0;
[COLOR="Blue"]for[/COLOR] n = 1:2:sum_count
sum = sum + (((((-1)^((n-1)/2))/n^2)*sin((n*pi*t(k+1)))/peroid));
[COLOR="Blue"]end[/COLOR]
f(k+1) = sum*(8/(pi^2));
[COLOR="Blue"]end[/COLOR]
plot(t,f)
EDIT:
Never mind, I just set the iteration count higher and it works.
Last edited: