Orbiter-Forum  

Go Back   Orbiter-Forum > Far Side of the Moon > Math & Physics
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Notices

Math & Physics Mathematical and physical problems of space flight and astronomy.

Reply
 
Thread Tools
Old 11-24-2010, 01:50 PM   #1
n72.75
Donator
 
n72.75's Avatar


Default MATLAB Fourier Transform of a Triangle Wave

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:

Code:
clear;
clc;
format long;

itteration_count = 50;
sum_count = 50;
peroid = 2*pi;
origin = 0;

t = origin:peroid/itteration_count:peroid;
f = 1:itteration_count+1;


for k = 0:itteration_count
    sum = 0;
    for n = 1:2:sum_count
        sum = sum + (((((-1)^((n-1)/2))/n^2)*sin((n*pi*t(k+1)))/peroid));
    end
    f(k+1) = sum*(8/(pi^2));
end

plot(t,f)
EDIT:
Never mind, I just set the iteration count higher and it works.

Last edited by n72.75; 11-24-2010 at 05:35 PM.
n72.75 is offline   Reply With Quote
Reply

  Orbiter-Forum > Far Side of the Moon > Math & Physics


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 12:46 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2007 - 2012, Orbiter-Forum.com. All rights reserved.