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!

Matlab Help Needed Meshgrid

  1. Dec 1, 2009 #1
    1. The problem statement, all variables and given/known data

    The distance to the horizon increases as you climb a mountain:
    d=sqrt(2rh+h^2)

    d=distance to the horizon
    r=radius's
    h=height of hill

    solve for Earth's and Mar's radius
    Earths radius Feet: 20924640
    Mars radius feet: 11132880

    for heights from 0ft-10,000ft

    3. The attempt at a solution

    This is what I did but I keep getting an error

    >> R=[20924640, 11132880]

    R =

    20924640 11132880

    >> H=0:1:10000

    >> [r,h]=meshgrid(R,H)

    >> d=sqrt((2*r.*h.)+(h.^2))
    ??? d=sqrt((2*r.*h.)+(h.^2))
    |
    Error: Unbalanced or unexpected parenthesis or bracket.

    >> d=sqrt(2*r.*h.+h.^2)
    ??? d=sqrt(2*r.*h.+h.^2)
    |
    Error: Unexpected MATLAB operator.

    I'm not exactly sure what the problem is, please help!
     
  2. jcsd
  3. Dec 1, 2009 #2
    also the problem says I have to use meshgrid...I know there's a way to do this without doing that...
     
  4. Dec 1, 2009 #3

    Mark44

    Staff: Mentor

    The problem is that you have an extra period in this line
     
  5. Dec 1, 2009 #4
    But I thought you have to put a period after each vector variable?
     
  6. Dec 1, 2009 #5

    Mark44

    Staff: Mentor

    No, you misunderstand. The period is part of the operator, not part of the variable, and means that the operation is to be applied to each element of the vector.
     
  7. Dec 2, 2009 #6
    Oh I see Thank you!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab Help Needed Meshgrid
  1. Need matlab help (Replies: 1)

  2. MATLAB Help needed! (Replies: 1)

  3. Matlab help needed (Replies: 3)

  4. Matlab Need Help (Replies: 1)

Loading...