![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/285709/image.png)
How does one plot phase portraits for systems of differential equations?
138 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm sort of new to this whole process and a lof of my homework for diff eq's asks for us to use technology to plot some of the solutions.
We just started last week on system of diff eq's and I wanted to learn how to do this with MATLAB. Be easy on me as I have very limited knowledge of the language.
The example I have on hand of something I've been asked to plot is the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/285681/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/285682/image.png)
Where x is a function of t.
Any help would be greayly appreciated. Thank in advance!
0 commentaires
Réponses (2)
Ameer Hamza
le 19 Avr 2020
Modifié(e) : Ameer Hamza
le 19 Avr 2020
See this: http://matlab.cheme.cmu.edu/2011/08/09/phase-portraits-of-a-system-of-odes/ to understand how to make phase portraits in MATLAB. The following shows an example without using for-loop for your equations.
[X1,X2] = meshgrid(-5:0.5:5);
xs = arrayfun(@(x,y) {odeFun([],[x,y])}, X1, X2);
x1s = cellfun(@(x) x(1), xs);
x2s = cellfun(@(x) x(2), xs);
quiver(x1s, x2s)
xlabel('x_1')
ylabel('x_2')
axis tight equal;
function dxdt = odeFun(t,x)
dxdt(1) = 5*x(1)-9*x(2);
dxdt(2) = 1*x(1)-5*x(2);
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/285709/image.png)
2 commentaires
Frantisek Stloukal
le 29 Avr 2021
Hi, how do i get the axis in the right place ? The stable point should be [0,0] not [11,11]... Thanks for answer.
Ahsan Mujtaba
le 5 Mai 2021
In this question, I wanted to ask that the all the possible initial consitions are being plotted?
Brian Hong
le 26 Jan 2022
There are also apps that you can use to plot your phase portrait. Here's one that we created recently: https://www.mathworks.com/matlabcentral/fileexchange/91705-phase-plane-and-slope-field-apps
0 commentaires
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!