PPLVM because because innit niit
Show older comments
I have been struggling to find simpler examples to put into matlab. I want to make athat looks like this: /D and y=A/B
i know there is an ode method and Euler's
any method will do aslong as its broken down please
:D
1 Comment
Star Strider
on 21 Apr 2016
All you need to do is to put my code into a for loop, changing the values of the coefficients each time to get the results you want. I would store the output in a cell array if you want to use them later in your code.
For the plot, use the hold function to plot all the phase plots on one axis, if that is what you want to do.
Answers (2)
Image Analyst
on 20 Apr 2016
0 votes
On the right side of this page I see references to File Exchange submissions. Did you look at those?
1 Comment
Maths Girl
on 21 Apr 2016
Star Strider
on 21 Apr 2016
Try this:
% dx/dt = Ax - Bxy
% dy/dt = -Cy + Dxy.
A = 4;
B = 1;
C = 4;
D = 1;
% MAPPING: x = xy(1), y = xy(2)
LV_Eqns = @(t,xy, A,B,C,D) [A.*xy(1) - B.*xy(1).*xy(2); -C.*xy(2) + D.*xy(1).*xy(2)];
tspan = linspace(0, 2);
[T,XY] = ode45(@(t,xy) LV_Eqns(t,xy, A,B,C,D), tspan, [1 1]);
figure(1)
plot(T, XY)
grid
legend('Prey', 'Predator')
title('Time Domain Plot')
figure(2)
plot(XY(:,1), XY(:,2))
grid
axis equal
title('Phase Plane Plot')
xlabel('X')
ylabel('Y')
You may need a loop for different values of ‘A’ and ‘C’. This code works for one set of constants, so I leave it to you to write the code for the rest of the constants. You may need a cell array to efficiently store the output of the ode45 call, since that would probably be easier than storing them in a numeric array. I will also leave the other plots to you.
1 Comment
Image Analyst
on 21 Apr 2016
Star doesn't have the Crystal Ball Toolbox (yet), so you're going to have to show the loop you've created. Also explain in detail what "doesnt seem to work" means to you.
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!