ode45 with boundary conditions

42 ビュー (過去 30 日間)
Rick
Rick 2014 年 10 月 11 日
コメント済み: Rick 2014 年 10 月 11 日
Hello,
If I have boundary conditions such as at x = 0, the temperature is T1, and at x = L, temperature is T2, how do I incorporate that into ode45? can you span two different parameters? I am trying to solve fourier's law of condution
Qdot = -kA dT/dx
Here is my code, but when I run it the temperature at the end is not 300 like I want it to be
k0 = 5;
beta = 10;
k = @(T) k0*(1+beta*T);
xspan = [0 10]; % meters
L = 10; % meters
T1 = 300;
Tf = 100;
A = 10;
Qdot = ((-k0*A)/L)*(Tf + (beta/2)*Tf^2 - T1 + (beta/2)*T1^2);
dTdx = @(x,T) Qdot/(-k(T)*A);
[X, T] = ode45(dTdx,xspan,T1);
plot(X,T)
xlabel('distance (meters)')
ylabel('Temperature (C)')
title('Temperature vs. distance')

回答 (2 件)

Marc
Marc 2014 年 10 月 11 日
Try using bvp4c or bvp5c for boundary value problems.
ode45 is a initial value problem.
  1 件のコメント
Rick
Rick 2014 年 10 月 11 日
I have never seen this function. How can I incorporate it into this problem? It seems like the second argument for the boundary conditions is a function handle, but I just want the boundary conditions to be at x=0, T=T1, and at x=L, T=T2

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


haMed
haMed 2014 年 10 月 11 日
Your Problem is discretized on x and you are integrating the resulting ode problem by ode-solver.
In this case I try to include the boundary conditions in the discretized equations. Or to represent the boundary conditions as states.
  1 件のコメント
Rick
Rick 2014 年 10 月 11 日
I don't understand your response. How can I do whatever you are trying to say?

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

カテゴリ

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