1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need some help w/matlab

  1. Feb 9, 2009 #1
    1. The problem statement, all variables and given/known data
    A 75.0 g ball with radius 10cm is dropped. I am supposed to write a program that plots y as a function of time, including acceleration due to gravity and drag force of D=0.25*area*velocity.

    2. Relevant equations

    3. The attempt at a solution
    Here's what I tried:

    >> n=21;
    >> t=zeros(1,n);
    >> v=zeros(1,n);
    >> y=zeros(1,n);
    >> h=0.5;
    >> g=-9.80;
    >> m=0.075;
    >> A=pi*0.10*0.10;
    >> for i = 2:n
    ??? Error using ==> mtimes
    Inner matrix dimensions must agree.

    t is time, h is time increment, m is mass, a is total acceleration, A is area

    I don't understand the error that I am making. Could someone please help me?
  2. jcsd
  3. Feb 9, 2009 #2


    User Avatar

    Well, the cause for that error is that the default multiplication operation in Matlab is the matrix multiply. For something like this, you do not want the matrix multiplication - you want to extract just the item you are currently working on and use that value. There are some other problems too, but we can start by fixing that.

    Also, it is always best to have a thorough understanding of exactly what you are trying to get the code to do in each section before coding - do you have all of that worked out?
  4. Feb 10, 2009 #3


    User Avatar

    Complementing what cjl said, you should make:
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Need some help w/matlab
  1. Matlab help needed (Replies: 3)

  2. Matlab Need Help (Replies: 1)