MATLAB: Input argument “ke” is undefined.

argument 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

Best Answer

Hi Rita,
did you put in your S-function block three parameters to be passed as ke, kec and ku?
Titus
Related Question