Plotting 3D graph with ODEs
이전 댓글 표시
Hello there, I am looking for a possible way to plot 3D surface/graphs/plot from the data set I get from a system of ODEs that I created and solved using ode45, but I am unsure of how to get it.
Lets say I have the function files of the system of ODEs,and each time I run, I manipulate the parameters one by one to see their effect on the ans I get. For eg, I started off with the parameter A=0, and B = 3, which allows me to get population(t). Then I changed one of the parameter each time, A = 0, 20, 40, 60, 80 100 respectively. For each value of A, I also changed the B= 3, 6, 9, 12. respectively. Isit possible for me to plot a combined 3D plot of A, B and the population(t) and is there a better way/less tedious way to program this? If so, what is the suggested steps that I should take or do?
Thanks in advance!
답변 (1개)
J. Alex Lee
2020년 8월 21일
0 개 추천
If your ODE result "population(t)" a scalar value, then yes, you can use surf() if your [A,B] is defined using meshgrid.
댓글 수: 5
Clement Koh
2020년 8월 21일
J. Alex Lee
2020년 8월 21일
[A,B] = meshgrid((0:20:100),(3:3:12))
PT = nan(size(A)); % preallocate
for k = 1:numel(A)
PT(k) = % whatever number to extract from your ODE solution
end
Does it help?
If you are saying "population(t)" is actually a list of values, not just a number, then you should think harder about what it means to draw the plot you are thinking of.
Clement Koh
2020년 8월 21일
편집: Clement Koh
2020년 8월 21일
J. Alex Lee
2020년 8월 21일
In a 3D plot, you have available 3 coordinates, x,y,z. You are using up (x,y) with your A and B values. You can represent a "point" at that (x,y) with another single value z. How do you expect a plot to look if you want multiple values of z stacked onto each other at that single (x,y)? Even if you did do that, how would you interpret the interrelation among those multiple stacked points (their relation in time, e.g.)?
Clement Koh
2020년 8월 21일
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!