声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3014|回复: 2

[控制系统类] 警告为In an assignment A(I) = B, the number of elements in B and

[复制链接]
发表于 2009-3-30 23:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
在用similunk仿真时警告为:Error in 'sxinde/S-Function' while executing M-File S-function 'abcd', flag = 2 (update), at time 0. MATLAB error message:
In an assignment  A(I) = B, the number of elements in B and
I must be the same.
那是什么原因呀?


S-函数为:function [sys,x0,str,ts] = nevercellPID(t,x,u,flag,k)
switch flag,
  case 0,
    [sys,x0,str,ts]=mdlInitializeSizes;
  case 2,
    sys=mdlUpdate(t,x,u);
  case 3,
    sys=mdlOutputs(t,x,u,k);
  case {1,4,9}
    sys=[]
  otherwise
    error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates  = 0;
sizes.NumDiscStates  = 6;
sizes.NumOutputs     = 1;
sizes.NumInputs      = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;   % at least one sample time is needed
sys = simsizes(sizes);
x0  = [0.1 0.1 0.1 0 0 0];
str = [];
ts  = [];
function sys=mdlUpdate(t,x,u)
x(6)=u-x(5)-x(4);
x(4)=u-x(5);
x(5)=u;
x(1)=x(1)+20*u*x(4);
x(2)=x(2)+5*u*x(5);
x(3)=x(3)+10*u*x(6);
function sys=mdlOutputs(t,x,u,k)
sys=k*(x(1)*x(4)+x(2)*x(5)+x(3)*x(6))/(x(1)+x(2)+x(3));
回复
分享到:

使用道具 举报

发表于 2009-3-31 08:55 | 显示全部楼层
在更新那里有错误 看看你的u

评分

1

查看全部评分

 楼主| 发表于 2009-4-1 16:39 | 显示全部楼层
哦,确实是我的u弄错了,现在好了,谢谢你啊!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-26 07:17 , Processed in 0.054901 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表