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

MATLAB plotting error?

  1. Jun 7, 2010 #1

    I've written a piece of code in MATLAB, to depict the function x(t)

    I have the Fourier coefficients of this function as following:

    a(k) = 1/(k.*pi)^2

    where k is even and otherwise a(k) = 0.

    also we know that x(t+5) = x(t)

    my code is :
    Code (Text):

    function [zaribX] = Ak(k)  

        if ~((mod(k,2) == 1) || k==0)  
        else zaribX=0;

    function [x] = FunctionX(Kmax,t)
    x = 0;
        for m = 0:Kmax
            f = 2 .* abs(Ak(m)) .* cos( m .* ((2.*pi)./5) .* t + angle(Ak(m)));
            x = x+f;
    problem is, when MATLAB plots the function, it appears to have a period of 2.5 , and not 5. Could anyone help me see what's going wrong? Thanks a lot.

  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - MATLAB plotting error Date
Matlab Plotting Coordinate Transformations in Matlab Feb 12, 2018
Matlab Plotting animations (time-evolution) Jan 17, 2018
Does anyone had this plotting problem with MATLAB? Dec 23, 2017
Matlab Matlab's plot command Nov 30, 2017
Matlab Matlab -- how to make a smooth contour plot? Jun 28, 2017