Fix MATLAB Code Error: Input Argument "S" is Undefined

  • Context: MATLAB 
  • Thread starter Thread starter plexus0208
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary

Discussion Overview

The discussion revolves around a MATLAB code error related to an undefined input argument "S" in a function. Participants are exploring the cause of the error and potential solutions, focusing on function definitions and variable scopes within MATLAB programming.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether "S" has been defined prior to calling the function, suggesting that it may not be defined within the function itself.
  • Another participant suggests trying to call the function from another M-file, implying that the error may arise from directly running the function file.
  • A participant points out that the function is being called from within itself, indicating that the call to the function should be placed outside the function body.
  • There is a query regarding the definitions of "E" and "lambda" within the function, which are not provided in the initial code snippet.

Areas of Agreement / Disagreement

Participants express differing views on the cause of the error, with no consensus reached on the best solution. Multiple competing explanations are presented regarding the function's structure and variable definitions.

Contextual Notes

There are unresolved questions about the definitions of certain variables ("E" and "lambda") and the overall structure of the function, which may affect the execution of the code.

plexus0208
Messages
49
Reaction score
0
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
 
Physics news on Phys.org
has S been defined prior to calling the function?? if not, then it isn't defined within the function itself.
 
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?
 
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.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
18K
Replies
5
Views
8K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
4
Views
17K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K