How to solve a System of First Order ODE
1 次查看(过去 30 天)
显示 更早的评论
There are two tanks T1 and T2. T1 has 100 gallons of water, T2 has 150 pounds of salt inside and has the total mass of 100 gallons of mixed water. Every minute 2 gallons of water flows into the oppoiste tank.
y1 is the amount of salt T1 tank has. y2 is the amount of salt T2 has.
I got the equation.
y'1 = -0.02y1 + 0.02y2
y'2 = 0.02y1 - 0.02y2
it says the initial value is y1(0) = 0, y2(0) = 150 (this is obvious of course)
now I dont know anything about Matlab. But I want to graph some things.. which are
1) how do I get the graph of y1 and y2?
2) how do I get the Phase Portrait graph of this?
I would really appreciate your help thanks!
1 个评论
Jan
2021-5-19
"I dont know anything about Matlab"
Then please read the "Getting Started" chapters of the documentation and perform Matlab's Onramp. It would be inefficient, if the forum explains, what the "=" means in "a=1".
采纳的回答
Girijashankar Sahoo
2021-5-19
clc
clear all
close all
%t=[0:0.01:100];
syms y1(t) y2(t)
ode1 = diff(y1) == -0.02*y1 + 0.02*y2;
ode2 = diff(y2) == 0.02*y1 + -0.02*y2;
cond1 = y1(0) == 0;
cond2 = y2(0) == 150;
conds = [cond1; cond2];
odes = [ode1; ode2]
[y1, y2] = dsolve(odes,conds)
fplot(t,y1)
hold on
fplot(t,y2)
xlabel('t')
legend('y1','y2')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!