basin for attraction of multiple attractor
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ajay
el 2 de Sept. de 2023
Comentada: Kalyanashis
el 9 de Feb. de 2024
how can basin of attraction of multiple attractor for a three dim system can plot as i am just able to plot only for one attractor and don't have an idea how to plotbasin of attraction for multiple attractor.
Respuesta aceptada
Varun
el 11 de Sept. de 2023
Editada: Varun
el 11 de Sept. de 2023
Hi Ajay,
I understand that you are currently able to plot basin of attraction for one attractor, but you want to plot basin of attraction for multiple attractions.
To achieve this, you can modify the existing code by introducing an array of attractor coordinates. You define an array “attractor” that holds the coordinates of all the attractors you want to consider. .
Then, during the loop that checks if the trajectory converges to an attractor, you iterate over each attractor in the attractors array and break the loop as soon as a match is found. The value assigned to “basin(i)” represents the index of the attractor that the point converges to.
Please refer the updated code:
% Lorenz system parameters
clear all;
clc;
alpha = 10;
row= 28;
beta = 8/3;
% Define the Lorenz system equations
lorenz = @(t, xyz) [alpha * (xyz(2) - xyz(1));
xyz(1) * (row - xyz(3)) - xyz(2);
xyz(1) * xyz(2) - beta * xyz(3)];
% Define the attractor coordinates
attractors = [ % Add the coordinates of your attractors here
0, 0, 0;
10, -10, 20;
-10, 10, 30
];
% Define the time span for simulation
tspan = [0, 5];
% Number of points for the grid
num_points = 20;
% Create a grid of initial conditions for x, y, and z
x_range = linspace(-30, 30, num_points);
y_range = linspace(-30, 30, num_points);
z_range = linspace(0, 50, num_points);
[X, Y, Z] = meshgrid(x_range, y_range, z_range);
% Create a colormap for plotting
colormap([1 0 0; 0 0 1]); % Red and blue
% Initialize a matrix to store basin of attraction information
basin = zeros(size(X));
% Loop through all initial conditions
for i = 1:numel(X)
x0 = X(i);
y0 = Y(i);
z0 = Z(i);
% Simulate the Lorenz system from (x0, y0, z0)
[~, sol] = ode45(lorenz, tspan, [x0, y0, z0]);
% Check if the trajectory converges to any of the attractors
for j = 1:size(attractors, 1)
if norm(sol(end, :) - attractors(j, :)) < 1.0
% Mark this point as part of the basin of attraction
basin(i) = j; % Use the index of the attractor as the value
break; % Break the loop if a match is found
end
end
end
% Plot the basin of attraction
figure;
slice(X, Y, Z, basin, [], [], []);
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Basin of Attraction for Lorenz Attractors');
colorbar;
axis tight;
Hope this helps.
7 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!