Input argument "flag" is undefined.

[EDIT: 20110610 00:29 CDT - reformat - WDR]
Hi, I,m trying to use this function but I get this error:
"Input argument "flag" is undefined".
Please help me...
function [out1,out2,out3]=func(flag,s,x,e,alpha,beta,gamma);
switch flag
case 'b';
out1=zeros(size(s));
out2=s;
case 'f';
out1=((s-x).^(1-alpha))/(1-alpha);
out2=-(s-x).^(-alpha);
out3=-alpha*(s-x).^(-alpha-1);
case 'g';
out1=gamma*x+e.*x.^beta;
out2=gamma+beta*e.*x.^(beta-1);
out3=(beta-1)*beta*e.*x.^(beta-2);
end

Antworten (2)

Oleg Komarov
Oleg Komarov am 26 Jan. 2011

0 Stimmen

For those who can't read your function:
function [out1,out2,out3]=func(flag,s,x,e,alpha,beta,gamma)
switch flag
case 'b';
out1=zeros(size(s));
out2=s;
case 'f';
out1=((s-x).^(1-alpha))/(1-alpha);
out2=-(s-x).^(-alpha);
out3=-alpha*(s-x).^(-alpha-1);
case 'g'; out1=gamma*x+e.*x.^beta;
out2=gamma+beta*e.*x.^(beta-1);
out3=(beta-1)*beta*e.*x.^(beta-2);
end
If you call it w/o supplying any arguments that's the exact error you get, i.e. it won't work if you don't say what "flag,s,x,e,alpha,beta,gamma" are:
>> func
??? Input argument "flag" is undefined.
Error in ==> func at 3
switch flag
You should call it with the necessary arguments, in the case of flag = 'b':
>> func('b',1)
ans =
0
Hope it's clear.
Oleg
Julia
Julia am 10 Aug. 2011

0 Stimmen

I'm having a similar problem with this code, it gives the error "Input argument "x" is undefined.
Error in ==> Circulator at 11 Stationary=x;"
Can you help?
function [Correlation,shift] = Circulator(x,z) %Finds relative amp of x and z for circle data
Stationary=x; Moving=z;
kk=1; Correlation=[]; m=17; for n=0:.1:1 Correlation(kk,1)=Stationary(m,1)*Moving(m+n,1); kk=kk+1; end shift=max(Correlation);
end

1 Kommentar

Friedrich
Friedrich am 10 Aug. 2011
Sounds like you are calling Circulator(x,y) as Circulator(). So please pass arguments to your function Circulator.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 26 Jan. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by