Results 1 to 2 of 2

Math Help - Multiple array generation in Matlab

  1. #1
    Junior Member
    Joined
    May 2008
    Posts
    50

    Multiple array generation in Matlab

    theta=5
    offset=1.5

    for i=1:10

    force=cosd(theta)+offset

    force_array(i)=force
    theta=theta+1

    end


    This code will generate an array, force_array, with the ten different forces per theta and offset value(s).

    What if I want to generate 3 different force arrays all from the same theta values (in the loop) but three different offset values? Any suggestions? Thanks,
    Kim
    Last edited by Kim Nu; January 29th 2009 at 01:42 PM. Reason: Make question more clear
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    May 2008
    Posts
    50
    In other words I essentially want a program that does this

    theta=5
    offset=1.5

    for i=1:10

    force1=cosd(theta)+offset

    force_array1(i)=force1

    theta=theta+1

    end

    theta=5
    offset=2.0

    for i=1:10

    force2=cosd(theta)+offset

    force_array2(i)=force2
    theta=theta+1

    end

    theta=5
    offset=7.0

    for i=1:10

    force3=cosd(theta)+offset

    force_array3(i)=force3
    theta=theta+1

    end


    There's gotta be a way to loop this using my original code. Any suggestions?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab - cell array
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 3rd 2010, 05:28 AM
  2. Matlab data cleaning - cell array to matrix problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 24th 2010, 09:08 AM
  3. Sorting the all array in MATLAB
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 13th 2010, 10:53 AM
  4. MATLAB - Random Number Generation
    Posted in the Math Software Forum
    Replies: 4
    Last Post: February 18th 2009, 06:03 AM
  5. Matlab--Problem with randn generation
    Posted in the Math Software Forum
    Replies: 2
    Last Post: November 16th 2008, 06:07 AM

Search Tags


/mathhelpforum @mathhelpforum