%%
%  Author: Peter Polcz (ppolcz@gmail.com) 
%  Created on 2023. December 07. (2023a)
%
% [3] Lü and Chen (2006). Generating multiscroll chaotic attractors: Theories, methods and
% applications. International Journal of Bifurcation and Chaos, World Scientific Pub Co
% Pte Ltd, 16(04):775-858, 2006.
%
% Chua circuit with a chaotic attractor with 9th scroll.


% In this parameter setup, the physical parameters R, C1, C2, L are given indirectly.
alpha = 10.82;
beta = 14.286;
a = 1.3;
b = 0.11;
c = 7;
d = 0;

h = @(x) -b*sin(x*pi/2/a + d);

f = @(t,x) [
    alpha * ( x(2) - h(x(1)) )
    x(1) - x(2) + x(3)
    -beta*x(2)
    ];

[t,x] = ode45(f,[0,1000],[1;1;1]/10);

fig = figure(2);
Tl = tiledlayout(3,2,'TileSpacing','tight','Padding','compact');

% Plot the solution in the phase diagram.
ax = nexttile([3,1]);
plot3(x(:,1),x(:,2),x(:,3))

xlabel x
ylabel y
zlabel z
grid on, box on
axis vis3d

% Plot the x1, x2, and x3 functions
ax1 = nexttile; grid on, box on, hold on
plot(t,x(:,1))

ax2 = nexttile; grid on, box on, hold on
plot(t,x(:,2))

ax3 = nexttile; grid on, box on, hold on
plot(t,x(:,3))

Link = linkprop([ax1,ax2,ax3],'XLim');
xlim([0,200])

