Index exceeds the number of array elements (1)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to plot x1, y1, x2 and y2 for different values of a1 and a2. Please help me to resolve the issue. Thanks in advance.
clear all; close all; clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+
% Simulation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OMEGA1=1:0.5:14.5;
OMEGA2=1:0.5:14.5;
for num1=1:length(OMEGA1)
for num2=1:length(OMEGA2)
%value of constants
omega1=OMEGA1(num1);
omega2=OMEGA2(num2);
a1=0.1;
a2=0.2;
a3=0.3;
a4=0.4;
a5=0.5;
G=1;C12=0.01;C21=0.02;
dt=0.01; %step size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x11(1)=0.5;
y11(1)=0.5;
x12(1)=0.5;
y12(1)=0.5;
x13(1)=0.5;
y13(1)=0.5;
x14(1)=0.5;
y14(1)=0.5;
x15(1)=0.5;
y15(1)=0.5;
x21(1)=1;
y21(1)=1;
x22(1)=1;
y22(1)=1;
x23(1)=1;
y23(1)=1;
x24(1)=1;
y24(1)=1;
x25(1)=1;
y25(1)=1;
for i=2:10000
x11(i)=x11(i-1)+((a1-x11(i-1)^2-y11(i-1)^2)*x11(i-1)-omega1*y11(i-1)+G*C12*(x21(i-1)-x11(i-1)))*dt;
x12(i)=x12(i-1)+((a2-x12(i-1)^2-y12(i-1)^2)*x12(i-1)-omega1*y12(i-1)+G*C12*(x22(i-1)-x12(i-1)))*dt;
x13(i)=x13(i-1)+((a3-x13(i-1)^2-y13(i-1)^2)*x13(i-1)-omega1*y13(i-1)+G*C12*(x23(i-1)-x13(i-1)))*dt;
x14(i)=x14(i-1)+((a4-x14(i-1)^2-y14(i-1)^2)*x14(i-1)-omega1*y14(i-1)+G*C12*(x24(i-1)-x14(i-1)))*dt;
x15(i)=x15(i-1)+((a5-x15(i-1)^2-y15(i-1)^2)*x15(i-1)-omega1*y15(i-1)+G*C12*(x25(i-1)-x15(i-1)))*dt;
y11(i)=y11(i-1)+((a1-x11(i-1)^2-y11(i-1)^2)*y11(i-1)+omega1*x11(i-1)+G*C12*(y21(i-1)-y11(i-1)))*dt;
y12(i)=y12(i-1)+((a2-x12(i-1)^2-y12(i-1)^2)*y12(i-1)+omega1*x12(i-1)+G*C12*(y22(i-1)-y12(i-1)))*dt;
y13(i)=y13(i-1)+((a3-x13(i-1)^2-y13(i-1)^2)*y13(i-1)+omega1*x13(i-1)+G*C12*(y23(i-1)-y13(i-1)))*dt;
y14(i)=y14(i-1)+((a4-x14(i-1)^2-y14(i-1)^2)*y14(i-1)+omega1*x14(i-1)+G*C12*(y24(i-1)-y14(i-1)))*dt;
y15(i)=y15(i-1)+((a5-x15(i-1)^2-y15(i-1)^2)*y15(i-1)+omega1*x15(i-1)+G*C12*(y25(i-1)-y15(i-1)))*dt;
x21(i)=x21(i-1)+((a1-x21(i-1)^2-y21(i-1)^2)*x21(i-1)-omega2*y21(i-1)+G*C21*(x11(i-1)-x21(i-1)))*dt;
x22(i)=x22(i-1)+((a2-x22(i-1)^2-y22(i-1)^2)*x22(i-1)-omega2*y22(i-1)+G*C21*(x12(i-1)-x22(i-1)))*dt;
x23(i)=x23(i-1)+((a3-x23(i-1)^2-y23(i-1)^2)*x23(i-1)-omega2*y23(i-1)+G*C21*(x13(i-1)-x23(i-1)))*dt;
x24(i)=x24(i-1)+((a4-x24(i-1)^2-y24(i-1)^2)*x24(i-1)-omega2*y24(i-1)+G*C21*(x14(i-1)-x24(i-1)))*dt;
x25(i)=x25(i-1)+((a5-x25(i-1)^2-y25(i-1)^2)*x25(i-1)-omega2*y25(i-1)+G*C21*(x15(i-1)-x25(i-1)))*dt;
y21(i)=y21(i-1)+((a1-x21(i-1)^2-y21(i-1)^2)*y21(i-1)+omega2*x21(i-1)+G*C21*(y11(i-1)-y21(i-1)))*dt;
y22(i)=y22(i-1)+((a2-x22(i-1)^2-y22(i-1)^2)*y22(i-1)+omega2*x22(i-1)+G*C21*(y12(i-1)-y22(i-1)))*dt;
y23(i)=y23(i-1)+((a3-x23(i-1)^2-y23(i-1)^2)*y23(i-1)+omega2*x23(i-1)+G*C21*(y13(i-1)-y23(i-1)))*dt;
y24(i)=y24(i-1)+((a4-x24(i-1)^2-y24(i-1)^2)*y24(i-1)+omega2*x24(i-1)+G*C21*(y14(i-1)-y24(i-1)))*dt;
y25(i)=y25(i-1)+((a5-x25(i-1)^2-y25(i-1)^2)*y25(i-1)+omega2*x25(i-1)+G*C21*(y15(i-1)-y25(i-1)))*dt;
end
end
end
figure
hold on
plot(x11,'r')
plot(x12,'g')
plot(x13,'r')
plot(x14,'g')
plot(x15,'r')
4 Kommentare
Ive J
am 6 Jan. 2021
Except for your misleading script indentation, your script has no errors. You need to exactly clarify what you mean by issue.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!