Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Index exceeds matrix dimensions

2 vues (au cours des 30 derniers jours)
sihem bk
sihem bk le 5 Nov 2018
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaires
madhan ravi
madhan ravi le 5 Nov 2018
Huge mess
sihem bk
sihem bk le 5 Nov 2018
in what

Réponses (1)

Tally Miller
Tally Miller le 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.
  1 commentaire
sihem bk
sihem bk le 5 Nov 2018
i'm trying to plot this

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by