I want to extract outer points of my plot(Chaotic Data Points) and plot it with the extracted outer points.

alpha = 0;
% Initial conditions
x = 1;
y = 1;
z = 1;
% Time step
dt = 0.01;
% Arrays to store the trajectory points
x_traj = [];
y_traj = [];
z_traj = [];
% Loop over time
for t = 0:dt:300
% Calculate x', y', and z' for the current alpha
x_prime = (25*alpha + 10)*(y - x);
y_prime = (28 - 35*alpha)*x - x*z + (29*alpha - 1)*y;
z_prime = x*y - ((alpha+8)/3)*z;
% Update x, y, and z
x = x + dt*x_prime;
y = y + dt*y_prime;
z = z + dt*z_prime;
% Store the trajectory points
x_traj = [x_traj, x];
y_traj = [y_traj, y];
z_traj = [z_traj, z];
end
% Plot x and y
figure;
plot(x_traj, y_traj);
xlabel('x')
ylabel('y');
title('Phase Portrait: x and y');
grid on;
I have written this code and from this I have got the following plot
;
There are a lot of self intersecting points in this plot.So I want a exact shape but without using the selfintersecting points.Then I used Convhull command
convhull_indices = convhull(x_traj, y_traj);
plot(x_traj(convhull_indices), z_traj(convhull_indices), 'r');
and I got this plot
But this is not the excat representation of the previous shape
I am actually looking something like this.Which command or procedure I should use.

 Réponse acceptée

hello
maybe this ?
I needed to use a refine time increment dt (1/10th of the original value) so that the outer points are close enough to make the boundary smooth and not with zigzags between outer and more inner points
hope it helps
alpha = 0;
% Initial conditions
x = 1;
y = 1;
z = 1;
% Time step
dt = 0.001;
% Arrays to store the trajectory points
x_traj = [];
y_traj = [];
z_traj = [];
% Loop over time
for t = 0:dt:300
% Calculate x', y', and z' for the current alpha
x_prime = (25*alpha + 10)*(y - x);
y_prime = (28 - 35*alpha)*x - x*z + (29*alpha - 1)*y;
z_prime = x*y - ((alpha+8)/3)*z;
% Update x, y, and z
x = x + dt*x_prime;
y = y + dt*y_prime;
z = z + dt*z_prime;
% Store the trajectory points
x_traj = [x_traj; x];
y_traj = [y_traj; y];
z_traj = [z_traj; z];
end
% Plot x and y
figure;
plot(x_traj, y_traj);
hold on
xlabel('x')
ylabel('y');
title('Phase Portrait: x and y');
grid on;
% k = boundary(___,s) specifies shrink factor s using any of the previous syntaxes.
% s is a scalar between 0 and 1. Setting s to 0 gives the convex hull,
% and setting s to 1 gives a compact boundary that envelops the points.
% The default shrink factor is 0.5.
k = boundary(x_traj, y_traj,0.95);
plot(x_traj(k), y_traj(k), 'm');

5 commentaires

this is an alternative that does not need dt increment refined as before
I simply used this fex submission :
this is the result obtained :
alpha = 0;
% Initial conditions
x = 1;
y = 1;
z = 1;
% Time step
dt = 0.01;
% Arrays to store the trajectory points
x_traj = [];
y_traj = [];
z_traj = [];
% Loop over time
for t = 0:dt:100
% Calculate x', y', and z' for the current alpha
x_prime = (25*alpha + 10)*(y - x);
y_prime = (28 - 35*alpha)*x - x*z + (29*alpha - 1)*y;
z_prime = x*y - ((alpha+8)/3)*z;
% Update x, y, and z
x = x + dt*x_prime;
y = y + dt*y_prime;
z = z + dt*z_prime;
% Store the trajectory points
x_traj = [x_traj; x];
y_traj = [y_traj; y];
z_traj = [z_traj; z];
end
% Plot x and y
figure;
plot(x_traj, y_traj);
hold on
xlabel('x')
ylabel('y');
title('Phase Portrait: x and y');
grid on;
% home made outer boudary selection
% obtained by looking at top / bottom y points (intersection with a
% vertical line scrolling from left to right)
xx = linspace(min(x_traj),max(x_traj),100);
x_store = [];
y_store = [];
yrange = ceil(max(abs(y_traj)));
for ci =1:numel(xx)
[x0,y0,iout,jout] = intersections(x_traj,y_traj,[xx(ci) xx(ci)],[-yrange yrange]); % FEX : https://fr.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections?s_tid=srchtitle
[y0max,~] = max(y0);
[y0min,~] = min(y0);
x_store = [x_store;xx(ci);xx(ci)];
y_store = [y_store;y0min;y0max];
end
plot(x_store, y_store, '*r');
When I was trying to run the code.I am getting this error. Unrecognized function or variable 'intersections'.
Error in UnifiedChaos (line 606)
[x0,y0,iout,jout] = intersections(x_traj,y_traj,[xx(ci) xx(ci)],[-yrange yrange]); % FEX : https://fr.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections?s_tid=srchtitle.
Any idea why I am getting this.
sure
I was saying that you need to download the function 'intersections.m'. at this page : Fast and Robust Curve Intersections - File Exchange - MATLAB Central (mathworks.com)
if you prefer , it's also in the attachment here
store it in your matlab path
as always, my pleasure
if my submission has helped you, do you mind accepting it ? tx

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by