The code for this simulation [provided below] is functionally similiar to the Javascript code used in our HTML5 simulation. The parameters and initial conditions are the same. Also, like the HTML 5 simulation, the values for alpha and beta are abstract and do not correspond to any real circuit. Both use a set of solving functions to plot the points at each time step using Chua's equations. This Matlab simulation uses ODE45, a medium order method, for the calculations.
Matlab, of course, provides other tools for examining the scroll and attractors involved, as well as other ways of manipulating the view on the signal output.
%----------Chua.m---------- function out = chua(t,in) x = in(1); y = in(2); z = in(3); alpha = 15.6; beta = 28; m0 = -1.143; m1 = -0.714; h = m1*x+0.5*(m0-m1)*(abs(x+1)-abs(x-1)); xdot = alpha*(y-x-h); ydot = x - y+ z; zdot = -beta*y; out = [xdot ydot zdot]';
%----------StartChua.m---------- [t,y] = ode45(@chua,[0 100],[0.7 0 0]); plot3(y(:,1),y(:,2),y(:,3)) grid
The animation above comes from a Matlab simulation of a Chua's circuit with non-dimensionless equations---that is, parts of the equation relate to actual physical components of the circuit and can be adjusted to simulate modifcations or the various components you might want to try. For example, we have modelled a saturated double scroll attractor below by adjusting the values for C1 and R.
In the associated code below you can see how each piece corresponds to the dynamics of the equations and easily modify them to see what changes occur in what conditions. It should be noted that this code is specifically for the diagram shown below (also on our diagram page) and would be different for other variations of the Chua's Circuit.
Schematic of simulated circuit
Simulation of modified circuit showing saturation due to component value changes to C1 and R
%----------RealChua.m---------- function out = RealChua(t,in) x = in(1); %v_1 y = in(2); %v_2 z = in(3); %i_L C1 = 10*10^(-9); %10nF C2 = 100*10^(-9); %100nF R = 1800; %1.8k Ohms G = 1/R; %Chua Diode************************************* R1 = 220; R2 = 220; R3 = 2200; R4 = 22000; R5 = 22000; R6 = 3300; Esat = 9; %9V batteries E1 = R3/(R2+R3)*Esat; E2 = R6/(R5+R6)*Esat; m12 = -1/R6; m02 = 1/R4; m01 = 1/R1; m11 = -1/R3; m1 = m12+m11; if(E1>E2) m0 = m11 + m02; else m0 = m12 + m01; end mm1 = m01 + m02; Emax = max([E1 E2]); Emin = min([E1 E2]); if abs(x) < Emin g = x*m1; elseif abs(x) < Emax g = x*m0; if x > 0 g = g + Emin*(m1-m0); else g = g + Emin*(m0-m1); end elseif abs(x) >= Emax g = x*mm1; if x > 0 g = g + Emax*(m0-mm1) + Emin*(m1-m0); else g = g + Emax*(mm1-m0) + Emin*(m0-m1); end end %end Chua Diode************************************* %Gyrator********************************* R7 = 100; %100 Ohms R8 = 1000; %1k Ohms R9 = 1000; %1k Ohms R10 = 1800; C = 100*10^(-9); %100nF L = R7*R9*C*R10/R8; %18mH %end Gyrator****************************** % Chua's Circuit Equations xdot = (1/C1)*(G*(y-x)-g); ydot = (1/C2)*(G*(x-y)+z); zdot = -(1/L)*y; out = [xdot ydot zdot]';
%----------StartRealChua.m---------- [t,y] = ode45(@RealChua,[0 0.05],[-0.5 -0.2 0]); plot3(y(:,1),y(:,2),y(:,3)) grid