Error using myfun (line 15) Not enough input arguments.

1 view (last 30 days)
Hi can anybody help me to figure out what's wrong with this function? It keeps giving me the error: Error using myfun (line 15) Not enough input arguments.
Thank you so much
function S = myfun(c1,L_UC,L_US)
global r s
%Compression
if r==0;
lam1 = L_UC+1;
lam2 = 1./lam1;
lam3 = 1./lam1;
lam1sq=lam1.^2;
lam2sq=lam2.^2;
lam3sq=lam3.^2;
I1 = (lam1sq+lam2sq+lam3sq);
%Simple shear
else s=0;
lam1 = L_US+1;
lam2 = 1.;
lam3 = 1.;
lam1sq=lam1.^2;
lam2sq=lam2.^2;
lam3sq=lam3.^2;
I1 = (lam1sq+lam2sq+lam3sq);
end
S= c1.*(I1-3);

Accepted Answer

Sean de Wolski
Sean de Wolski on 10 Oct 2013
Edited: Sean de Wolski on 10 Oct 2013
How are you calling it? Are you are just pressing the play button (green triangle), then no inputs are passed to myfun. You need to call it with the expected inputs:
>>myfun(c1,L_UC,L_US)
Or if you do want to use the green play button, you need to set up run configurations or defaults. This can be done two ways: by clicking on the down arrow next to the play button and inserting the code you wish to run, i.e.:
myfun(c1,L_UC,L_US)
Or by putting defaults into your function. I.e. making the first line check if any inputs were provided and if they weren't, assigning them:
if ~nargin
%no inputs
c1 = pi;
L_UC = 10;
L_US = 'hello world';
end

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!