why do I receive error "Not enough Argument"
이전 댓글 표시
Hello
I am writting codes to a s-function block to create demo or animate of a liquid Tank ,but I have a problem which is "not enough Arguments".I am not sure if you know what is the problem,I have paste my written codes below.
Thank you
function [sys,x0,str,ts,setPt1,setPt2,waterx1,vessel1Hndl,vessel1Ht, vesselHndlList,waterY1,vessel2Hndl,lineHndl1,lineHndl2]=vesseldemo2project (u,flag,t,x)
switch flag==4
case 0
[sys,x0,str,ts,vesseldemo2project]=mdlInitializeSizes;
get(vesseldemo2project,'UserData') =vesselHndlList;
get( vesselHndlList(1),'YData');
yData(1)=yOffset;
yData(3:4)=[1 1]*u(2)+yOffset;
set( vesselHndlList(1),'YData',yData);
yData=get(x(2),'YData');
yData([3 4])=[1 1]*u(2)+yOffset;
set(x(2),'YData',yData);
yData=[1 1]*u(1)+1;
set(x(3),'YData',yData);
case 2
%Tank body details.................................
sys=mdlUpdate(t,x,u);
vessel1Ht=1;
vessel1Wid=1;
vessel1Init=0;
setPt1=0.5;
setPt2=0.75;
vesselx=[0 0 1 1]-0.5;
vesselY=[1 0 0 1];
line(1.1*vesselx*vessel1Wid+1,vesselY*vessel1Ht+0.95,'LineWidth',2,'Color','black');
% Draw the water..............................................
waterx1=vesselx*vessel1Wid+1;
waterx=vesselY*vessel1Init+1;
x=patch(waterx,waterx,'blue','EdgeColor','none');
% Draw the gray wall............................................
waterY1([1 2 5])=vessel1Ht*[1 1 1]+1;
waterY([3 4 ])=x*[1 1 ]+1;
vessel2Hndl=patch(waterx,waterY,[.9 .9 .9],'EdgeColor','none');
case 3
str = [];
ts = [.1 0];
vessel1Wid=1;
vessel1Ht=1;
vessel1Init=0;
setPt1=0.5;
setPt2=0.75;
vesselx=[0 0 1 1]-0.5;
vesselY=[1 0 0 1];
waterx1=vesselx*vessel1Wid+1;
waterx=vesselY*vessel1Init+1;
waterY1([1 2 5])=vessel1Ht*[1 1 1]+1;
waterY([3 4 ])=vessel1Init*[1 1 ]+1;
vessel1Hndl=patch(waterx,waterx,'blue','EdgeColor','none');
vessel2Hndl=patch(waterx,waterY,[.9 .9 .9],'EdgeColor','none');
lineHndl1=line([0 0.4],setPt1*[0.5 0.5]+1,'Color','red','LineWidth',4);
hlod on
lineHndl2=line([0 0.4],setPt2*[0.75 0.75]+1,'Color','red','LineWidth',4);
hold on
set(gcf, ...
'Color',[.9 .9 .9], ...
'UserData',[vessel1Hndl vessel2Hndl lineHndl]);
set(gca, ...
'XLim',[0 2],'YLim',[0 3.5], ...
'XColor','black','YColor','black', ...
'Box','on');
axis equal
xlabel('Water Level Control','Color','black','FontSize',10);
set(get(gca,'XLabel'),'Visible','on');
x0=0;
otherwise
error(message('vesseldemo:vesseldemo2project:UnhandledFlag', flag));
end
댓글 수: 2
Piyush Aggarwal
2020년 11월 9일
"Not enough arguments" error is simply an indicative of the fact that you are calling some MATLAB/user-defined function with the wrong syntactical signature. You will need to pass correct number of inputs arguments to any function. Look closely at the exact error message you are recieving. It will tell you which line and which function is causing the trouble.
KEYVAN PEBDANI SAHRAEI
2020년 11월 9일
채택된 답변
추가 답변 (1개)
Abhisek Pradhan
2020년 12월 13일
1 개 추천
This may be a case of defining and calling the function in the same script. If this is the case try separating them out and see if it works.
카테고리
도움말 센터 및 File Exchange에서 Simulation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!