Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab fourier series

  1. Aug 18, 2014 #1
    HI plz help me this could someone verify it for me plz find attachement

    clc;
    clear all;
    k=0;
    s=0;
    N=inf;
    for i=1:N
    s=s+(1/(k^2+1));
    k=k+1;
    end

    syms x n
    a0=1/pi*int(cosh(x),-pi,pi);
    an=1/pi*int(cosh(x)*cos(n*x),-pi,pi);
    bn=1/pi*int(cosh(x)*sin(n*x),-pi,pi);

    fs=0;

    for l=0:100
    fs=fs+(an*cos(l*x)+bn*sin(l*x))
    end

    fs-fs+a0/2;
     

    Attached Files:

    • TD.jpg
      TD.jpg
      File size:
      9.2 KB
      Views:
      65
  2. jcsd
  3. Aug 18, 2014 #2

    mathman

    User Avatar
    Science Advisor
    Gold Member

    The calculation of s looks OK. It could have been done slightly easier.
    N=inf;
    s=1;
    for k = 1:N
    s=s+(1/(k^2+1));
    end
    The Fourier series sum has a couple of errors. I would do the following:
    fs = a0/2;
    N = inf;
    for n = 1:N
    fs=fs+(an*cos(n*x)+bn*sin(n*x));
    end
     
  4. Aug 18, 2014 #3
    Thanks
     
  5. Aug 19, 2014 #4

    mathman

    User Avatar
    Science Advisor
    Gold Member

    A further simplification: Except for a0, the values of an and bn can be calculated inside the loop, so they don't have to be stored in advance.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted
Similar Discussions: Matlab fourier series
  1. Fourier Series (Replies: 4)

  2. Fourier Series (Replies: 2)

  3. Fourier Series (Replies: 3)

  4. Fourier Series (Replies: 0)

  5. Fourier series (Replies: 8)

Loading...