麻烦高手帮我看一下这个Matlab程序问题在哪
clearall;closeall;ts=0.01;N=100;A=[1,0;0,1];B=[1,0;-1,0];D=[-1,0;0,0]';K=[-0.3120,-0....
clear all;
close all;
ts=0.01;
N=100;
A=[1,0;0,1];
B=[1,0;-1,0];
D=[-1,0;0,0]';
K=[-0.3120,-0.1804;0.1316,-0.2924];
E=[1.9980,-0.4609;-0.4609,1.6118];
L=[-6.0332,-2.7349]';
M=[-1.1972,0.6945]';
W=randn(2,N);
%W=[100,20]';
%X=zeros(2,N);
X(:,1)=[130,70]';
%U=zeros(2,N);
U(:,1)=[100,20]';
%Z=zeros(2,N);
Z(:,1)=[100,20]';
for k=2:N
t(k)=k*ts;
%X(:,k)=A*X(:,k-1)+B*U(:,k-1)+D*W;
X(:,k)=A*X(:,k-1)+B*U(:,k-1)+D*W(:,k-1);
%Z(:,k)=0.01*Z(:,k-1)-1.4963*W;
Z(:,k)=0.01*Z(:,k-1)-1.4963*W(:,k-1);
U(:,k)=-K*(E*X(:,k-1)+L*W(:,k-1)+M*Z(:,k-1));
end
figure(1);
plot(t,X);
%plot(t,X,t,U);
figure(2);
plot(t,U);
figure(3);
plot(t,Z);
为什么总是出现下面的语句
??? Error using ==> mtimes
Inner matrix dimensions must agree. 展开
close all;
ts=0.01;
N=100;
A=[1,0;0,1];
B=[1,0;-1,0];
D=[-1,0;0,0]';
K=[-0.3120,-0.1804;0.1316,-0.2924];
E=[1.9980,-0.4609;-0.4609,1.6118];
L=[-6.0332,-2.7349]';
M=[-1.1972,0.6945]';
W=randn(2,N);
%W=[100,20]';
%X=zeros(2,N);
X(:,1)=[130,70]';
%U=zeros(2,N);
U(:,1)=[100,20]';
%Z=zeros(2,N);
Z(:,1)=[100,20]';
for k=2:N
t(k)=k*ts;
%X(:,k)=A*X(:,k-1)+B*U(:,k-1)+D*W;
X(:,k)=A*X(:,k-1)+B*U(:,k-1)+D*W(:,k-1);
%Z(:,k)=0.01*Z(:,k-1)-1.4963*W;
Z(:,k)=0.01*Z(:,k-1)-1.4963*W(:,k-1);
U(:,k)=-K*(E*X(:,k-1)+L*W(:,k-1)+M*Z(:,k-1));
end
figure(1);
plot(t,X);
%plot(t,X,t,U);
figure(2);
plot(t,U);
figure(3);
plot(t,Z);
为什么总是出现下面的语句
??? Error using ==> mtimes
Inner matrix dimensions must agree. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询