# an ode with arguements

5 ビュー (過去 30 日間)
Ray 2024 年 4 月 9 日

Here is my function file:
function dfdeta = mufun(eta,f,T)
pr = 1000;
dfdeta = [f(2); f(3); -f(1) * f(3); T(2); -pr*f(:,1)*T(2)];
end
and here is the code to call my function:
clear;
clc;
close all;
guessf = 0.4696;
guessT = .5;
[eta, f, T] = ode45(@mufun, [linspace(0,6,16)], [0; 0; guessf; 0; guessT]);
plot(eta,f);
blasius = table(eta, f(:,1), f(:,2), f(:,3), 'VariableNames',{'eta','f', 'f prime', 'f double prime'})
I was able to figure out the ode45 for just the eta and f variable, but now I have to have f defined in order to solve for T.

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

### 回答 (3 件)

James Tursa 2024 年 4 月 9 日

Create a new function handle with your extra stuff. E.g.,
mufunT = @(eta,f) mufun(eta,f,guessT)
[eta, f] = ode45(mufunT, [linspace(0,6,16)], [0; 0; guessf]);
But, this assumes you know T in advance. What do you mean by "solve for T"?
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Ray 2024 年 4 月 9 日
We are given a differential equation where these terms: T(2); -pr*f(:,1)*T(2) are needed. We found f previously when we did ode45 without those new terms. But in the differential equation we are given we have to have f(:,1) in order to solve.

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

Star Strider 2024 年 4 月 9 日
You have five differential equations and three initial conditions.
The initial conditions vector must have the same length as the number of differential equations.
Beyond that, you need to pass ‘T’ as an additional parameter:
[eta, f] = ode45(@(eta,f)mufun(eta,f,guessT), [linspace(0,6,16)], [0; 0; guessf]);
.
##### 6 件のコメント4 件の古いコメントを表示4 件の古いコメントを非表示
James Tursa 2024 年 4 月 10 日
@Ray Can you post an image of the differential equations you are trying to solve?
Ray 2024 年 4 月 10 日
It has to be as a pdf, the images came out wrong. Hope this makes sense.

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

Torsten 2024 年 4 月 10 日

You have to define your vector of solution variables as
y(1) = f, y(2) = f', y(3) = f'', y(4) = T, y(5) = T'
function dydeta = mufun(eta,y)
pr = 1000;
dydeta = [y(2); y(3); -y(1)*y(3)/2; y(5); -pr/2*y(1)*y(5)];
end
Further, your problem is a boundary value problem, not an initial value problem. Use "bvp4c", not "ode45" to solve.

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

### カテゴリ

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