Input argument "ke" is undefined.

function [sys,x0,str,ts] = kaiguan(t,x,u,flag,ke,kec,ku)
switch flag,
%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3,
sys=mdlOutputs(t,x,u,ke,kec,ku);
%%%%%%%%%%%%%%%%%%%%%%%
% GetTimeOfNextVarHit %
%%%%%%%%%%%%%%%%%%%%%%%
case {1,2,4,9}
sys=[];
%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
% end sfuntmpl
% %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts]=mdlInitializeSizes
% % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes;
sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 3; sizes.NumInputs = 2; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
% % initialize the initial conditions % x0 = [];
% % str is always an empty matrix % str = [];
% % initialize the array of sample times % ts = [0 0];
% end mdlInitializeSizes
% %============================================================================= % mdlDerivatives % Return the derivatives for the continuous states. %============================================================================= %
% end mdlDerivatives
% %============================================================================= % mdlUpdate % Handle discrete state updates, sample time hits, and major time step % requirements. %============================================================================= %
% end mdlUpdate
% %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u,ke,kec,ku)
if(abs(u(1))>0.3|abs(u(2))>0.1) sys(1)=0.6*ke; sys(2)=0.5*kec; sys(3)=ku+25; elseif(abs(u(1))>0.1|abs(u(2))>0.05) sys(1)=0.8*ke; sys(2)=0.6*kec; sys(3)=ku+10; else sys(1)=1.2*ke; sys(2)=kec; sys(3)=0.8*ku; end % end mdlOutputs
% %============================================================================= % mdlGetTimeOfNextVarHit % Return the time of the next hit for this block. Note that the result is % absolute time. Note that this function is only used when you specify a % variable discrete-time sample time [-2 0] in the sample time array in % mdlInitializeSizes. %============================================================================= %
% end mdlGetTimeOfNextVarHit
% %============================================================================= % mdlTerminate % Perform any end of simulation tasks. %============================================================================= % % end mdlTerminate
in the MATLAB, it says
??? Input argument "ke" is undefined.
Error in ==> s1 at 119
sys=mdlOutputs(t,x,u,ke,kec,ku);
when I wanna to run the mdl file,it says
Input argument "ke" is undefined.
I just change some args but follow the model. I a green hand, therefore, I donnot know where lies the mistake?
can anyone come to give a helping hand?
many thanks

3 Comments

I can't read that mess if you don't format it properly. Please edit, highlight all your code and press the 'Code' button.
Now, do you get this error when you call the function 'kaiguan'? If so, please provide the exact code that makes the call.
That's odd, I distinctly remember this question as being formatted before...
some sectenses whose function were explantion were just deleted
hope it will be clearer to identify

Sign in to comment.

 Accepted Answer

Titus Edelhofer
Titus Edelhofer on 21 May 2012
Hi Rita,
did you put in your S-function block three parameters to be passed as ke, kec and ku?
Titus

2 Comments

the program above was found in a paper written by a MSLA, however it proved to be wrong
just now my teacherhelped me solve the problem, I just simply cut off the "ke,kec,ku"
and it is now "function [sys,x0,str,ts] = kaiguan(t,x,u,flag)"
everything is fine
thanks a million!O(∩_∩)O~
could u please explain to me??? how to neglect the errror

Sign in to comment.

More Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Asked:

on 20 May 2012

Commented:

on 25 Jul 2014

Community Treasure Hunt

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

Start Hunting!