Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Index exceeds matrix dimensions

2 visualizzazioni (ultimi 30 giorni)
sihem bk
sihem bk il 5 Nov 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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')
  2 Commenti
madhan ravi
madhan ravi il 5 Nov 2018
Huge mess
sihem bk
sihem bk il 5 Nov 2018
in what

Risposte (1)

Tally Miller
Tally Miller il 5 Nov 2018
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.

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by