MATLAB Function Problem

  • MATLAB
  • Thread starter plexus0208
  • Start date
  • #1
49
0

Main Question or Discussion Point

I get the following error with my MATLAB code. Can anyone help me fix it? I don't see what is wrong.

----------------------------------------------------------------

??? Input argument "S" is undefined.

Error in ==> RCPrototype at 11
Wpay = Tmax/((CDA0/S)/CL + cd/CL + CL/(pi*AR)) - Wfuse;

-----------------------------------------------------------------

MATLAB CODE:

function [WpayMax, constraint] = RCPrototype(AR, S, lambda)

Wfuse = 2.5;
Tmax = 0.70;
CDA0 = 0.004;
cd = 0.028;
CL = 1.0;
tau = 0.11;
eps = 0.03;

Wpay = Tmax/((CDA0/S)/CL + cd/CL + CL/(pi*AR)) - Wfuse;
WpayMax = max(abs(Wpay));
constraint = 0.018*((Wfuse + Wpay)/(E*tau*(tau^2+eps^2)))*(1+lambda)^3*(1+2*lambda)*(AR^3);

[WpayMax, constraint] = RCPrototype(0.5,0.5,0.5);

end
 

Answers and Replies

  • #2
Dr Transport
Science Advisor
Gold Member
2,357
488
has S been defined prior to calling the function?? if not, then it isn't defined within the function itself.
 
  • #3
jhae2.718
Gold Member
1,161
20
Try calling the function from another M-file. I'm guessing you're trying to directly run the function file.

Also, what are "E" and "lambda" defined as in your function?
 
  • #4
131
0
You're calling the function from within the function:

Code:
constraint = 0.018*((Wfuse + Wpay ...

[B][WpayMax, constraint] = RCPrototype(0.5,0.5,0.5);[/B]

end
You need to put that outside the function body.
 

Related Threads on MATLAB Function Problem

Replies
3
Views
2K
Replies
1
Views
3K
Replies
2
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
19
Views
1K
  • Last Post
Replies
1
Views
24K
  • Last Post
Replies
2
Views
11K
Replies
2
Views
7K
  • Last Post
Replies
2
Views
5K
Top