Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Input argument "ke" is undefined.

Asked by Rita on 20 May 2012
Latest activity Commented on by sabarish on 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 Comments

Geoff on 21 May 2012

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.

Walter Roberson on 21 May 2012

That's odd, I distinctly remember this question as being formatted before...

Rita on 21 May 2012

some sectenses whose function were explantion were just deleted
hope it will be clearer to identify

Rita

Products

No products are associated with this question.

1 Answer

Answer by Titus Edelhofer on 21 May 2012
Accepted answer

Hi Rita,

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

Titus

2 Comments

Rita on 21 May 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 on 25 Jul 2014

could u please explain to me??? how to neglect the errror

Titus Edelhofer

Contact us