How to solve a System of First Order ODE

5 ビュー (過去 30 日間)
희준 박
희준 박 2021 年 5 月 19 日
コメント済み: 희준 박 2021 年 5 月 19 日
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
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
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')
  1 件のコメント
희준 박
희준 박 2021 年 5 月 19 日
Thanks so much you're a life savior!!!!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by