Using ode to solve a specific differential equation

1 回表示 (過去 30 日間)
Allison Reynolds
Allison Reynolds 2021 年 11 月 8 日
コメント済み: Star Strider 2021 年 11 月 8 日
I need help solving this specific differential equation using ode45 in MATLAB. The differential equation is k*(dT/dt)= A*Q*(1-b(T)) - S*c*E*(T^4). We have all of the values but I need code to solve and plot different solutions to the ode.
  2 件のコメント
William Rose
William Rose 2021 年 11 月 8 日
@Allison Reynolds, what have you done so far? When you say you need to solve and plot different solutions, what do you mean? Different initial conditions? Different values for the constants?
Please post what you have done so far, including values for the initial conditions and the constants.
William Rose
William Rose 2021 年 11 月 8 日
@Allison Reynolds, does Q(1-b(T)) mean Q*(1-b*T))? If not, then specify what the functions b and Q are.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2021 年 11 月 8 日
Try these —
% k*(dT/dt)= A*Q(1-b(T)) - S*c*E*(T^4)
odefcn = @(t,T,a,b,c,E,k,Q,S) (a*Q*(1-b*T) - S*c*E*(T^4))/k; % If 'Q' Is A Scalar
a = rand;
b = rand;
c = rand;
E = rand;
k = rand;
Q = rand;
S = rand;
tspan = [0 20];
ic = 0.42;
[t,T] = ode45(@(t,T)odefcn(t,T,a,b,c,E,k,Q,S), tspan, ic);
figure
plot(t,T)
grid
odefcn = @(t,T,a,b,c,E,k,Q,S) (a*Q(1-b*T) - S*c*E*(T^4))/k; % If 'Q' Is A Function
a = rand;
b = rand;
c = rand;
E = rand;
k = rand;
S = rand;
Q = @(x) sin(x) .* cos(x); % Make Something Up
tspan = [0 20];
ic = 0.42;
[t,T] = ode45(@(t,T)odefcn(t,T,a,b,c,E,k,Q,S), tspan, ic);
figure
plot(t,T)
grid
Experiment to get the desired result.
.
  2 件のコメント
William Rose
William Rose 2021 年 11 月 8 日
Nice compact and elegant solution by @Star Strider
Star Strider
Star Strider 2021 年 11 月 8 日
Thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by