Input argument "ke" is undefined.

4 Ansichten (letzte 30 Tage)
Rita
Rita am 20 Mai 2012
Kommentiert: sabarish am 25 Jul. 2014
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 Kommentare
Walter Roberson
Walter Roberson am 21 Mai 2012
That's odd, I distinctly remember this question as being formatted before...
Rita
Rita am 21 Mai 2012
some sectenses whose function were explantion were just deleted
hope it will be clearer to identify

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Titus Edelhofer
Titus Edelhofer am 21 Mai 2012
Hi Rita,
did you put in your S-function block three parameters to be passed as ke, kec and ku?
Titus
  2 Kommentare
Rita
Rita am 21 Mai 2012
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~
sabarish
sabarish am 25 Jul. 2014
could u please explain to me??? how to neglect the errror

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by