MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   数学 (https://www.labfans.com/bbs/forumdisplay.php?f=15)
-   -   求助,关于状态变量分析的内容,请高手指教啊。。。 (https://www.labfans.com/bbs/showthread.php?t=8302)

keke211 2009-05-13 11:04

求助,关于状态变量分析的内容,请高手指教啊。。。
 
matlab命令如下是可以运行的
A=[2,3;0,-1];B=[0,1;1,0];C=[1,1;0,-1];D=[1,0;1,0];
x0=[2;-1];
t=0:0.1:3;
f(:,1)=ones(1, length(t));
f(:,2)=exp(-3*t);
sys=ss(A,B,C,D);
y=lsim(sys,f,t,x0);
subplot(2,1,1);plot(t,y(:,1));
ylabel('yl(t)');xlabel('t');
grid on;
subplot(2,1,2);plot(t,y(:,2));
ylabel('y2(t)');xlabel('t');
grid on;
但是若把t=0:0.1:3;语句改为t=0:0.02:3;或是改成其他的时间间隔,就出现如下错误

??? Error using ==> unknown
Subscripted assignment dimension mismatch.

Error in ==> test21222 at 4
f(:,1)=ones(1,length(t));

hilbertyuan 2009-05-13 22:39

回复: 求助,关于状态变量分析的内容,请高手指教啊。。。
 
把程序改成如下的形式就可以了:
clear
close all

A=[2,3;0,-1];B=[0,1;1,0];C=[1,1;0,-1];D=[1,0;1,0];
x0=[2;-1];
t=0:0.02:3;
f(:,1)=ones(1, length(t));
f(:,2)=exp(-3*t);
sys=ss(A,B,C,D);
y=lsim(sys,f,t,x0);
subplot(2,1,1);plot(t,y(:,1));
ylabel('yl(t)');xlabel('t');
grid on;
subplot(2,1,2);plot(t,y(:,2));
ylabel('y2(t)');xlabel('t');
grid on;


其实就是在你的程序前面加上了清理工作区和关掉多余窗口的命令。我不知道该如何解释这个问题,不过在每次程序运行前最好能清理下工作区,避免不必要的错误出现


所有时间均为北京时间。现在的时间是 05:00

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.