How to solve a System of First Order ODE
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
희준 박
el 19 de Mayo de 2021
Comentada: 희준 박
el 19 de Mayo de 2021
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 comentario
Jan
el 19 de Mayo de 2021
"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".
Respuesta aceptada
Girijashankar Sahoo
el 19 de Mayo de 2021
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')
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!