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!

Homework Help: Matlab help! User defined function!

  1. Nov 7, 2012 #1
    I tried to make a user-defined function.
    function Ht=Height(t,V,Theta);

    but then i kept on getting Input argument "V" is undefined...

    can someone help me plz
  2. jcsd
  3. Nov 7, 2012 #2


    Staff: Mentor

    What you show above seems reasonable for the function definition. Show us how you are calling this function - that might be what's causing your error.
  4. Nov 7, 2012 #3
    Here's the function.

  5. Nov 7, 2012 #4


    Staff: Mentor

    This doesn't make any sense to me. Use the function you wrote (the Height function) to calculate height, and then pass the value returned by that function as the first parameter in your fminbnd function.
  6. Nov 8, 2012 #5
    You get that error when you try to run the function without giving it values for the arguments that you are passing into the function.

    If you go to matlab's command window type the function's name and then the values that you want to use. For example:

    Height(3, 4, 60)
    t = 3, V = 4, theta = 60
  7. Nov 8, 2012 #6


    User Avatar
    Science Advisor

    The problem is not the function, but the way you are trying to use it.

    The function fminbnd() expects to be passed a function of a single variable.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook