Info

此问题已关闭。 请重新打开它进行编辑或回答。

Index exceeds matrix dimensions

1 次查看(过去 30 天)
sihem bk
sihem bk 2018-11-5
关闭: MATLAB Answer Bot 2021-8-20
Hello,i'm trying to plot the synchronization error under the hybrid control, iget this error :
Index exceeds matrix dimensions.
Error in Untitled21 (line 16)
e(:,k+1)= (A*((Y(k ,:))-(x(:,k))))+(fy-fx);
and this my code :
clear all
clc
a=1.07;
b=0.3;
n= 50;
K(1)=0;
%Z(1)=0;
x(:,1)=[(-1.2) ; 0 ; 0.3 ];
y(1,:)=[(-1.54); 0 ; 0.46];
Y=transpose(y)
for k=1:n
%for Z=1:n
fx=[1-a*((x(1))^2)*(k) ; 0 ;0 ];
fy=[1-a*((Y(1))^2)*(k) ; 0 ; 0 ];
A=[0.12 -0.18 0;0 0.15 -0.18;0 0 0.18];
e(:,k+1)= (A*((Y(k ,:))-(x(:,k))))+(fy-fx);
K(k+1)=k;
%end
end
plot(K,e(1,:),'red')
hold on
plot(K,e(2,:),'green')
hold on
plot(K,e(3,:),'blue')

回答(1 个)

Tally Miller
Tally Miller 2018-11-5
I don't know what you are trying to do here, but you are getting the error message because you are trying to access x(:,k) when x is a matrix with the dimensions [3,1]. It happens once i is greater than 1.
The debugging tool might help you with this.

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by