Results 1 to 6 of 6

Math Help - Mapping arrays to use negative indexes

  1. #1
    Newbie
    Joined
    Jun 2009
    Posts
    3

    Mapping arrays to use negative indexes

    For an assignement in my Continuous Time Signals class, we were asked to calculate the fourier series of a given x(t). The problem I'm running into is we are asked to calculate the Dn in my m-file from -10 to 10 (course Matlab cannot handle negative indices and 0 since the numerical values of Dn are stored in an array). Is there any kind of solution that I could use to get aorund this to make it calculate from -10 to 0?

    Thank you a lot.

    Attached is my m-file with the necessary functions. The main m-file is called Prob2. Particularly the end where plotting of Dn is where I'm mainly talking about.
    Attached Files Attached Files
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by n4cag View Post
    For an assignement in my Continuous Time Signals class, we were asked to calculate the fourier series of a given x(t). The problem I'm running into is we are asked to calculate the Dn in my m-file from -10 to 10 (course Matlab cannot handle negative indices and 0 since the numerical values of Dn are stored in an array). Is there any kind of solution that I could use to get aorund this to make it calculate from -10 to 0?

    Thank you a lot.

    Attached is my m-file with the necessary functions. The main m-file is called Prob2. Particularly the end where plotting of Dn is where I'm mainly talking about.
    DArry=zeros(1,21)
    offset=11;

    Now when you require a reference to Dn you use DArry(n+offset)

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2009
    Posts
    3
    Using this still gives me problems since I've changed where my references of Dn are to DArry(n+offset). Maybe I'm just implementing this wrong?

    ??? Index exceeds matrix dimensions.

    Error in ==> problem_2test at 70
    [nnd' DArry(n+offset).']

    Also since now I've implemented in right I believe, my matrixes are just 0....
    Last edited by n4cag; June 14th 2009 at 06:18 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by n4cag View Post
    Using this still gives me problems since I've changed where my references of Dn are to DArry(n+offset). Maybe I'm just implementing this wrong?

    ??? Index exceeds matrix dimensions.

    Error in ==> problem_2test at 70
    [nnd' DArry(n+offset).']

    Also since now I've implemented in right I believe, my matrixes are just 0....
    Yes, that is just a declaration and how to access the correct components, you still have to fill the array with the appropriate values.

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jun 2009
    Posts
    3
    I hate sounding like a newbie with Matlab but how do I call my values of Dn into the array?
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by n4cag View Post
    I hate sounding like a newbie with Matlab but how do I call my values of Dn into the array?
    Suppose you could index arrays as you want, then how would you calculate the coefficients?

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Comparing two arrays of data
    Posted in the Statistics Forum
    Replies: 0
    Last Post: March 7th 2012, 02:05 AM
  2. Big Fractions and Big Arrays
    Posted in the LaTeX Help Forum
    Replies: 3
    Last Post: May 12th 2011, 02:13 AM
  3. Complex open mapping & conformal mapping problems.
    Posted in the Differential Geometry Forum
    Replies: 1
    Last Post: February 22nd 2011, 07:26 AM
  4. Groups, subgroups and indexes
    Posted in the Advanced Algebra Forum
    Replies: 6
    Last Post: January 20th 2011, 04:58 AM
  5. Sub-indexes
    Posted in the LaTeX Help Forum
    Replies: 5
    Last Post: July 29th 2008, 05:10 AM

Search Tags


/mathhelpforum @mathhelpforum