Error in Chaotic attracter
이전 댓글 표시
Hi I am trying to plot the following equations
t_n = c - 6/(1+x_n ^2 + y_n^2);
w_n+1 =1+u*(w_n*cos(t_n)-s_n*sin(t_n));
s_n+1=u*(w_n *sin(t_n)-s_n*cos(t_n));
x_n+1=1-a*s_n+1^2 + b*w_n+1;
y_n+1 = mu*w_n+1*(1-s_n+1);
% where a=1.3; b=4; w= 0.1; s=0.1; c=0.4; u=0.9; mu=4;
the possible out come should be

Here is my code and the possible output
a=1.3; b=4; w= 0.1; s=0.1; c=0.4; u=0.9; mu=4;
x(1)=0.1;y(1)=0.1
n=10000;
% Initialize for n=0
%t(1)=0.4-(6/(1+x(1)^2+y(1)^2));
t(1)=0.4-(6/(1+s^2+w^2));
w(1)=1+u*(w*cos(t(1))-s*sin(t(1)));
s(1)=u*(w*sin(t(1))-s*cos(t(1)));
x(1)=1-a*s(1)^2 + b*w(1);
y(1) = mu*w(1)*(1-s(1));
for i=2:n
t(i)=c-(6/(1+s(i-1)^2+s(i-1)^2)); %% may replace with x and y
w(i)=1+u*(w(i-1)*cos(t(i))-s(i-1)*sin(t(i)));
s(i)=u*(w(i-1)*sin(t(i))-s(i-1)*cos(t(i)));
x(i)=1-a*s(i)^2+b*w(i);
y(i)=mu*w(i)*(1-s(i));
end
plot(x,y,'.','MarkerSize',4);
Here is the output.

Can anyone help me .
댓글 수: 4
Walter Roberson
2021년 2월 24일
편집: Walter Roberson
2021년 2월 24일
Style point:
t(1)=0.4-(6/(1+s^2+w^2));
You hard-coded 0.4 there, but you should have used c
I would recommend that you pre-initialize your vectors. And make sure that you use (1) indexing when initializing the (1) locations.
lilly lord
2021년 2월 24일
lilly lord
2021년 2월 24일
Remember, the following is just changes to style, which also make the code more efficient.
Please check, though, the order that you initialize t w s x y. At the moment the order is important: you use the initial s value to compute t(1) and w(1) and then you assign to s(1) using the t values you calculated. If you changed the order you would get something different.
Perhaps you should be assigning to (2) indices at that point, and loop starting from 3 ?
a=1.3; b=4; c=0.4; u=0.9; mu=4;
n=10000;
x = zeros(1,n); y = zeros(1,n); t = zeros(1,n); w = zeros(1,n); s = zeros(1,n);
x(1) = 0.1; y(1) = 0.1; w(1) = 0.1; s(1) = 0.1;
% Initialize for n=0
t(1) = c-(6/(1+s(1)^2+w(1)^2));
w(1) = 1+u*(w(1)*cos(t(1))-s(1)*sin(t(1)));
s(1) = u*(w(1)*sin(t(1))-s(1)*cos(t(1)));
x(1) = 1-a*s(1)^2 + b*w(1);
y(1) = mu*w(1)*(1-s(1));
for i=2:n
t(i)=c-(6/(1+s(i-1)^2+s(i-1)^2)); %% may replace with x and y
w(i)=1+u*(w(i-1)*cos(t(i))-s(i-1)*sin(t(i)));
s(i)=u*(w(i-1)*sin(t(i))-s(i-1)*cos(t(i)));
x(i)=1-a*s(i)^2+b*w(i);
y(i)=mu*w(i)*(1-s(i));
end
plot(x,y,'.','MarkerSize',4);
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Nonlinear Dynamics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
