1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    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! 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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Matlab help User Date
Need help with matlab matrices Nov 27, 2015
Building a truss with matlab -- Need help Nov 22, 2015
Matlab help please... Nov 14, 2015
Matlab error, can you help? Jan 30, 2015
MATLab: user written function question help Mar 20, 2009