Not Enough Input Arguments? What Am I doing wrong??

1 view (last 30 days)
hello,
I'm trying to program a function (omega).
the equation for my function is w=sqrt(36.75*sin(theta)-(390.625*(sqrt(.72*(1+sin(theta)))-sqrt(.72))^2))
I need to add the condition that when w=0, theta=theta_max. This is how I programmed the function but i keep getting error messages. What am I doing wrong?
function w = omega(theta)
w=sqrt(36.75*sin(theta)-(390.625*(sqrt(.72*(1+sin(theta)))-sqrt(.72))^2));
for theta=0:(90*pi)/180
if(w==0)
theta_max=theta_max+theta;
end
end
end
  3 Comments
Walter Roberson
Walter Roberson on 28 Apr 2014
What the heck are all those "magic numbers" ? why 36.75? why 0.72? why 390.625 ? Two of those look like degree values ?!
Jessica St.Julien
Jessica St.Julien on 28 Apr 2014
the numbers were given from the problem...is it my numbers that are messing up the function? i didnt think that would be the problem.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 28 Apr 2014
You never define theta_max, or passed it in. What is its value? And what is that for loop for? It looks like nonsense.
  2 Comments
Jessica St.Julien
Jessica St.Julien on 28 Apr 2014
Im very new to MATLAB, so i really dont know if I'm using it correctly.
I have an equation w=sqrt(36.75*sin(theta)-(390.625*(sqrt(.72*(1+sin(theta)))-sqrt(.72))^2)). I need to solve for theta when w=0. theta has to be within the range of 0 to 90 degrees.
I thought that was how you program the function to do that but judging from these answers to my question i guess Im failing epically at MATLAB.
Image Analyst
Image Analyst on 28 Apr 2014
Edited: Image Analyst on 28 Apr 2014
Maybe this???
function w = omega(theta)
w=sqrt(36.75*sin(theta)-(390.625*(sqrt(.72*(1+sin(theta)))-sqrt(.72))^2));
end
You're computing w, not inputting it, so you can't say that when w = 0, theta = theta_max. You're not even passing theta_max back out of the function! Maybe you want to answer a different question and that is "What is theta such that w = 0?"

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 28 Apr 2014
You cannot run the program by clicking on the Run button or pressing F5. You need to go down to the command line and type it in there, passing in an argument, such as
omega(1.32302)
  1 Comment
Jessica St.Julien
Jessica St.Julien on 28 Apr 2014
now im confused. I have to find theta (between the given range 0-->90deg), when w=0 and that solved theta is then my theta max..i dont know theta so how can i type it in?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!