how to plot bifurcation graph

4 次查看(过去 30 天)
shiv gaur
shiv gaur 2022-11-20
回答: William Rose 2022-11-20
this the program of rossler we want to vary value b from 0 to 2
Tstart = 0.0;
Tend = 1000.0;
Nt = 20000;
dT = (Tend-Tstart)/Nt;
X0 = 0.0;
Y0 = 1.0;
Z0 = 0.0;
N = 20;
A=0.2;
B=0.2;
C=5.7;
// Initialize coefficient arrays
T = zeros(Nt+1,1);
X = zeros(Nt+1,1);
Y = zeros(Nt+1,1);
Z = zeros(Nt+1,1);
a = zeros(N+1,1);
b = zeros(N+1,1);
c = zeros(N+1,1);
T(1) = 0.0;
X(1) = X0;
Y(1) = Y0;
Z(1) = Z0;
for j = 2:Nt+1
a(1) = X(j-1);
b(1) = Y(j-1);
c(1) = Z(j-1);
for k = 1:N
SC = 0.0;
for i= 0:k-1
SC = SC+ a(i+1)*c(k-i);
end
a(k+1) = (-b(k) - c(k))/k;
b(k+1) = (a(k)+A*b(k))/k ;
c(k+1) = (SC+B-C*(c(k)))/k ;
end
x = a(1);
y = b(1);
z = c(1);
for k = 2:N+1
x = x + a(k)*dT^(k-1);
y = y + b(k)*dT^(k-1);
z = z + c(k)*dT^(k-1);
end
%Prepare for T = T + dT
T(j) = T(j-1) + dT;
X(j) = x;
Y(j) = y;
Z(j) = z;
end
plot(T,X,'Color','red')
the value of b vary from 0 to 2 plot the graph b vs x this the program of power series rossler

回答(1 个)

William Rose
William Rose 2022-11-20
I do not understand what you are bdoing with a(), b(), and c() inside the main loop (the loop "for j=2:Nt+1, ..., end"). For example, you have the inner loop
for k = 2:N+1
x = x + a(k)*dT^(k-1);
y = y + b(k)*dT^(k-1);
z = z + c(k)*dT^(k-1);
end
where N=20. Why do you want to do any calcuations involving the 20th power of dT?
Add an outer loop that varies B over the desired range. For each value of B, I recommend that you use ode45() to solve the differential equations, since ode45() is much faster and more accurate that the forward Euler method which you appear to use. AFter solving the system with ode45(), use findpeaks(x) and findpeaks (-x) to find the maximum and minimum values of x during the final 200 seconds or 500 seconds or some appropriate time range. You will probably experiment to determine the appropriate time range to use with findpeaks(). Plot the minimum and maximum values of x, which you will have found with findpeaks(), versus the parameter B. If there are B values for which x approaches a steady state, then findpeaks() will not find any peaks. In such a situaiton, just find, and plot, the steady state value of X, versus the corresponding B value.
Good luck!

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by