请教(不知错误怎么改)
function = getfile(t,x,u,flag)switch flag
case 0
=mdlInitializeSizes;
case 3
sys=mdlOutputs(t,x,u);
case {1,2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function =mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates= 0;
sizes.NumDiscStates= 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 0;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0= [];
str = [];
ts= [-1 0];
function sys=mdlOutputs(t,x,u)
%a=1;
%b=2;
%filename=('C:\Program Files\MATLAB\R2006b\work\simulink\102_7.tif');
%I=imread(filename);
%M=double(I);
a=;
b=;
I=a+b;
sys =I; 提示错误是:Output returned by S-function 'getfile' in 'sumwe/S-Function' during flag=3 call must be a real vector of length 1.请高手指点一下,不胜感激! 那位大哥指点一下,真的很急。 function sys=mdlOutputs(t,x,u)
%a=1;
%b=2;
%filename=('C:\Program Files\MATLAB\R2006b\work\simulink\102_7.tif');
%I=imread(filename);
%M=double(I);
a=;
b=;
I=a+b;
sys =I;
你这个输出是不受输入控制的,sizes.DirFeedthrough = 0; 我已经将sizes.DirFeedthrough = 0,但还是提示同样的错误。 sizes.NumOutputs = -1;
sizes.NumInputs =-1;
ts= [-1 0];为什么是-1 0?如果连续的就用0 0
function sys=mdlOutputs(t,x,u)
a=;
b=;
I=a+b;
sys =I;
你这个outputs写的没有意义的,因为没用到输入变量所以呢,diret为0,
错误上写的length是1的嘛,你的sys输出为5 7 9 length为3啊
回复 #5 cdwxg 的帖子
谢谢你的解答,我想问怎样才能将length改为3呢? sizes.NumOutputs = 1;改为sizes.NumOutputs = 3;
页:
[1]