System of 2 differential equations
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Filip Jackowski
am 14 Apr. 2019
Kommentiert: Star Strider
am 21 Apr. 2019
I'm trying to express the following two differential equations in matlab in a form that will allow me to input them into a solver such as ode45. How would I input the following equations into matlab:
dC/dt = (-exp((-10/(T+273)))*C
dT/dt = 1000*(exp((-10)/(T+273))*C-10*(T-20)
where C and T are concentration and temperature (dependent variables) and t is time (independent variable).
0 Kommentare
Akzeptierte Antwort
Star Strider
am 14 Apr. 2019
The code you posted has errors, specifically unbalanced parentheses. I edited your equations to correct this, however I am not absolutely certain that my changes produce the correct result.
Try this:
% % % MAPPING: y(1) = C, y(2) = T
CTfcn = @(t,y) [-exp(-10/(y(2)+273))*y(1); 1000*(exp(-10/(y(2)+273))*y(1)-10*(y(2)-20))];
tv = linspace(0, 1E-3);
ic = [0, 0];
[T,Y] = ode45(CTfcn, tv, ic);
figure
plot(T,Y)
grid
legend('C', 'T')
The first row of ‘CTfcn’ is ‘C’, the second is ‘T’.
I also do not know what the initial conditions should be. I use [0,0] here, however they do not appear to have a significant effect on the ‘T’ result, regardless what their values are. Please provide the correct initial conditions, and please check to be certain your equations are correct as posted, and as I coded them.
6 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!