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!