MathWorks => Matlab => Topic started by: kimsel on April 06, 2012, 10:40:50 AM
I want to solve a series of ordinary differential equations (ODE). Both are first order.
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:
Now, i am needing to solve equations system:
1.05*x" + 1.155*x' + 133.333*x + 0.043*y" = 0
0.86*x" + y" + 0.254*y' + 161.333*y = 0
With conditions: x(0) = 0.015; x'(0) = 0;
I has used commands as:
>> a = 1.05;
>> b = 1.155;
>> c = 133.333;
>> d = 0.043;
>> e = 0.86;
>> f = 1;
>> g= 0.254;
>> h = 161.333;
>> syms x y t;
>> [x,y] = dsolve('a*D2x + b*Dx + c*x + d*D2y = 0, e*D2x + f*D2y + g*Dy + h*y = 0' , 'x(0) = 0.015,Dx(0)=0' , 't')
but error, i don't know why, i hope that everyone can help me. Thank you so much