How do I solve two Ordinary Differential equations using Matlab?
Here are the two differential equations:
dx/dt = 5.18(1-x)/T -->Equation - 1
dT/dt = 3.165(1-x)+0.4(300-T) -->Equation - 2
I want to solve them using Matlab.
In the Matlab editor write the following code:
function yp = programs(t,y)
Save this file as programs.m
Then add it to the path by clicking the run button.
Now to solve the equations type the following code in the workspace window:
[t,y]=ode45(@programs,[0 5], [0,20])
[0 5] is the initial and final value of time (assuming that you are differentiating with respect to time). [0,20] is the initial values of the variables: x and T.
To plot the results, you can use the plot function. Type the following code in the workspace window: