Results 1 to 3 of 3

Math Help - MATLAB - Need Help

  1. #1
    Newbie
    Joined
    May 2008
    Posts
    3

    MATLAB - Need Help

    Hi guys! I have to write a program to simulate a jump with a parachute, actually i have written a part without opening the parachute. But if I try running it I keep getting this error:

    ??? Error using ==> plus
    Matrix dimensions must agree.

    Error in ==> parachute at 24
    s=[s,s+ds];
    My source code:

    Code:
    clear all
    m=90;               % mass of jumper
    cm=0.43;            % cw-Value (value of the air-resistance)
    Am=1;               % "surface area" of jumper
    g=9.81;             
    roh=1.2929;         % density air
    dt=1;               % at which interval values will be calculated
    
    h=2000;             % total height
    
    k=(cm*Am*roh)/2;    % constant part of the formula for acceleration with air-resistance
    a=g;                % a at beginning
    v=0;                % v at beginning
    t=0;                % t at beginning
    s=0;                % s(height jumper already passed) at beginning
    
    
    % jump's duration
    ti=h/(sqrt(2*m*g/(cm*Am*roh)));
    ti=floor(ti);
    
    for t=1:dt:ti
        ds=v*dt;
        s=[s,s+ds];
        a=[a,g-(k/m)*v^2];
        dv=a*dt;
        v=[v,v+dv];
        t=[1:0.1:ti];
    end
    
    plot(t,v,'b')
    grid on
    hold on
    plot(t,a,'r')
    grid on
    hold on
    I'd be very happy if someone could help me.

    Sorry if my English isn't really good at some points, even so I hope you can understand it


    Best regards,
    unique
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Code:
    % jump's duration
    ti=h/(sqrt(2*m*g/(cm*Am*roh)));
    ti=floor(ti);
     
    for t=1:dt:ti
        ds=v*dt;
        s=[s,s+ds];
        a=[a,g-(k/m)*v^2];
        dv=a*dt;
        v=[v,v+dv];
        t=[1:0.1:ti];
    end
    you are effectivly redefiining the loop control variable inside the loop, and I don't care if it is allowed you should never do it. The other thing is what do you think this actualy does?

    Second by the look of it you are continualy appending new elements on the end of your vectors, this is very wastefull of processing time and power, you know how big the arrays are going be so create them that size.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2008
    Posts
    3
    Thanks a lot for your help!
    Now I first create all the vectors with the right length and after I fill in the values.

    Works fast and good now
    Later I'll (try to) add the part while opening the parachute.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 03:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 01:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 04:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 05:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 11:39 PM

Search Tags


/mathhelpforum @mathhelpforum