Using ODE 45 function to solve differential equation

1 次查看(过去 30 天)
I have figured out how to use the Ode 45 equation using this function and it works perfectly find.
function dw_dt = equation_(t,w)
a = 5.05;
b = 2; A=1;
w(A) = a*w(A)^(0.6)-b*w(A);
when i call the function into the script
time_period = [0:.25:20];
w0 = [0.5];
[t,w] = ode45(@equation_,time_period,w0);
, this function works perfectly fine, but now I'm trying to solve for dt/dw, so the equation given, is below, so basically in trying to solve for the time given the weight and initial time of 0.
dt/dw = 1/(a*w^(.6)-b*w)
I'm not sure if the proper to right it in matlab is.
dt = 1/(a*w(1)^(.6)-b*w(1))
given that a is a=5.05 and b=2 and the w range is 0<= w <=20
how will i be able to write the call function if I'm not given a time interval,since thats what I'm trying to solve for?
  1 个评论
Sudarshan Kolar
Sudarshan Kolar 2017-2-27
Stephanie, you can have an independent variable other than time when using ode45. You are thinking in the right direction.
function dtdw = equation2(w,t)
dtdw = 1/(a*w^(.6)-b*w);
end
[w,t] = ode45(@equation2,[0 20],[0])
In fact the documentation mentions that 't' is simply a evaluation point and y is a solution.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by