How to make a graph oscillate continuously

1 view (last 30 days)
Margo
Margo on 8 Dec 2014
Hello, I have an assignment. I have 4 variables that influence each other both positively and negatively. The influence is seen as lambda. I need to figure out values for each lambda so that the graph will oscillate continuously. I have inputted some values, but I am still confused. There is no influence of x4 on x2 and vice versa.
function dx = Dpop(t,x)
%ode function %Save this file in the 'work' folder.
global s
L11 = -0.01; L12 = 0.05; L13 = -0.04; L14 = 0.05; L21 = -0.02; L22 = -0.01; L23 = 0.04; L24 = 0; L31 = 0.02; L32 = -0.03; L33 = -0.01; L34 = -0.05; L41 = -0.02; L42 = 0; L43 = 0.04; L44 = -0.01;
%SYSTEM OF ODE dx = zeros(size(x));
dx(1) = (x(1) * L11 + x(2) * L21 + x(3) * L31 + x(4) * L41) * x(1) * (s - x(1));
dx(2) = (x(1) * L12 + x(2) * L22 + x(3) * L32 + x(4) * L42) * x(2) * (s - x(2));
dx(3) = (x(1) * L13 + x(2) * L23 + x(3) * L33 + x(4) * L43) * x(3) * (s - x(3));
dx(4) = (x(1) * L14 + x(2) * L24 + x(3) * L34 + x(4) * L44) * x(4) * (s - x(4));
%%COPY AND PAST ONTO THE MATLAB PROMPT global s
s = 1; time = 10000; %number of hours or time units x0 = [0.01, 0.7, 0.4, 0.5]; % starting point/initial condition options = odeset('RelTol',1e-8,'AbsTol', [1e-16 1e-16 1e-16 1e-16]); [Ta,xa] = ode45(@Dpop,[0 time],x0, options); %numerical integration
figure plot(Ta,xa(:,1),'-b', Ta,xa(:,2),'--k', Ta,xa(:,3),'-r', Ta,xa(:,4),'--g')
%figure %plot(Ta,xa)

Answers (0)

Community Treasure Hunt

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

Start Hunting!