I have reproduced a similar plot of the Rossler attractor with the following script “rough_rossler_script.m”:
function rossler_attractor_RK4
k1 = h * rossler(t, y, a, b, c);
k2 = h * rossler(t + 0.5*h, y + 0.5*k1, a, b, c);
k3 = h * rossler(t + 0.5*h, y + 0.5*k2, a, b, c);
k4 = h * rossler(t + h, y + k3, a, b, c);
Y(i+1,:) = y + (k1 + 2*k2 + 2*k3 + k4)/6;
plot3(Y(:,1), Y(:,2), Y(:,3), 'LineWidth', 1.5);
title('Rössler Attractor with RK4');
function dydt = rossler(t, y, a, b, c)
dydt(3) = b + y(3)*(y(1) - c);
Output plot from the “rough_rossler_script.m”:
To make the plot smoother, the step size (h) must be decreased because it will lead to the calculation of more points along the trajectory. The step size (h) is reduced to 0.01 from the earlier code where it was 0.175.
The modified script “smooth_rossler_script.m” is given below:
function rossler_attractor_RK4_smooth
k1 = h * rossler(t, y, a, b, c);
k2 = h * rossler(t + 0.5*h, y + 0.5*k1, a, b, c);
k3 = h * rossler(t + 0.5*h, y + 0.5*k2, a, b, c);
k4 = h * rossler(t + h, y + k3, a, b, c);
Y(i+1,:) = y + (k1 + 2*k2 + 2*k3 + k4)/6;
plot3(Y(:,1), Y(:,2), Y(:,3), 'LineWidth', 1.5);
title('Smooth Rössler Attractor with RK4');
function dydt = rossler(t, y, a, b, c)
dydt(3) = b + y(3)*(y(1) - c);
Output plot from “smooth_rossler_script.m”:
Hope it helps!