# Matlab help! User defined function!

I tried to make a user-defined function.
function Ht=Height(t,V,Theta);
Ht=V*t*sin(Theta)-4.9*t.^2;

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

can someone help me plz

Related Engineering and Comp Sci Homework Help News on Phys.org
Mark44
Mentor
I tried to make a user-defined function.
function Ht=Height(t,V,Theta);
Ht=V*t*sin(Theta)-4.9*t.^2;

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

can someone help me plz
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.

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.
Here's the function.

Ht=fminbnd(@Height,0,5000,V,Theta);

Mark44
Mentor
Here's the function.

Ht=fminbnd(@Height,0,5000,V,Theta);
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.

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

uart