高手请进 帮忙解答一下关于S-Function的问题
本帖最后由 坐看杂草丛生 于 2010-12-27 10:44 编辑小弟对正弦波采集200点作为S-function模块的输入,为什么老出现下面的错误
Output returned by S-function 'RestoreWaveform' in 'Test/ ' during flag=3 call must be a real vector of length 3
function = RestoreWaveform(t,x,u,flag)
w=pi/100;%一个周期采200个点-----定义部分
for column=0:1:3
switch column
case 0
for line=1:1:200
D1(line)=cos(w*line);
end
case 1
for line=1:1:200
D2(line)=sin(w*line);
end
case 2
for line=1:1:200
D3(line)=1;
end
end
end
C=; -----定义部分
D=C';
switch flag,
case 0,
=mdlInitializeSizes(D);
case 3,
sys=mdlOutputs(t,x,u,D);
case {1,2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function =mdlInitializeSizes(D)
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = size(D,1);
sizes.NumOutputs = size(D,2);
sizes.NumInputs = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = ones(sizes.NumDiscStates,1);
str = [];
ts = ;
function sys=mdlOutputs(t,x,u,D)
sys = inv(D'*D)*(D'*u);
帮你顶,版主看到就好了
页:
[1]