for the following code
function [sys,x0,str,ts] = Three_Tank(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts] = mdlInitializeSizes;
case 1,
sys = mdlDerivatives(t,x,u);
case 2,
sys = mdlUpdate(t,x,u);
case 3,
sys = mdlOutputs(t,x,u);
case 4,
sys = mdlGetTimeOfNextVarHit(t,x,u);
case 9,
sys = mdlTerminate(t,x,u);
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
I am getting this error
Input argument "flag" is undefined.
Error in ==> Three_Tank at 3 switch flag
Error in ==> load_system at 34 feval(sys);
Error in ==> getLinNormalModeBlocks at 22 load_system(mdl);
Error in ==> dlinmod at 107 [normalblks,normalrefs] = getLinNormalModeBlocks(model);

 채택된 답변

Friedrich
Friedrich 2011년 7월 8일

2 개 추천

Your function is not wrong. I think the problem is related to the way the function is called. The error indicates a call like
[sys,x0,str,ts] = Three_Tank(t,x,u)

댓글 수: 6

Krishna Kumar Kottakki
Krishna Kumar Kottakki 2011년 7월 8일
sorry Friedrich,
still it's not working.
Friedrich
Friedrich 2011년 7월 8일
It must be something like this. look at this
function repro( x,y,flag )
switch flag
case 1
disp('1')
otherwise
disp('otherwise')
end
end
>> repro(1,2,1)
1
>> repro(1,2)
??? Input argument "flag" is undefined.
Error in ==> repro at 3
switch flag
Jan
Jan 2011년 7월 8일
@Krishna: The error message says, that the 4th input "flag" is not defined. You call this function by "feval(sys)" - I assume "sys" is the function handle an you submit no inputs, but Three_Tank needs 4 inputs.
Therefore I think Friedrichs answer is correct. +1
Sean de Wolski
Sean de Wolski 2011년 7월 8일
@Friedrich: was that the episode where Homer had the crayon removed?
Friedrich
Friedrich 2011년 7월 8일
yes it was. its a screen from the scene where homer tries to say the Pythagorean theorem and fail totally.
Sean de Wolski
Sean de Wolski 2011년 7월 8일
Excelllllent /...\

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by