Vector input for ODE45
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Sirs, I have something like the below formula:
T=(A+B+C)+(D*T) dt where A, B and C are vectors with let me say (1,6000) length How Can I integrate this formula using ODE45, please help, and thanks in advance
採用された回答
Walter Roberson
2017 年 2 月 22 日
x0 = ... something same length as A;
[T, X] = ode45( @(t, x) f(t, X, A, B, C, D), tspan, x0);
function dy = f(t, y, A, B, C, D)
dy = (A + B + C) + (D*t);
... except of course if that were really your formula you would construct
x0 = ... something same length as A;
ApBpC = A + B + C;
[T, X] = ode45( @(t, x) f(t, X, ApBpC, D), tspan, x0);
function dy = f(t, y, ApBpC, D)
dy = ApBpC + (D*t);
11 件のコメント
Oday Shahadh
2017 年 2 月 22 日
Thanks Mr. Walter..
I will re-arrange the equation just in case this make a difference
Temp/dt=(A+B+C)+(D*Temp) I estimated the initial value of (Temp) D: is a constant dt: time interval
Walter Roberson
2017 年 2 月 22 日
Could you confirm that the form of the equation is
T(t) = (A+B+C) + (D*T(t))*diff(T(t),t)
If it is, then provided that you meet the theoretical boundary conditions, this has two solutions:
1)
T(t) = A + B + C %that is, constant in time
or 2)
T(t) = (lambertw(0, exp(-(A + B + C - t/D - (log(-exp(-(A + B + C - T0)/(A + B + C))*(A + B + C - T0)) + 1)*(A + B + C))/(A + B + C))/(A + B + C)) + 1)*(A + B + C)
where T0 is the boundary value at T(0)
Oday Shahadh
2017 年 2 月 22 日
編集済み: Walter Roberson
2017 年 2 月 22 日
T(t)=(A/dt+B/dt+C/dt)+D(T/dt);
A,B and C has been calculated by another algorithm in the script for(6000,1) length, and just(D= constant number)
Walter Roberson
2017 年 2 月 22 日
So to confirm,
T(t) == (A / diff(T(t),t) + B / diff(T(t),t) + C / diff(T(t),t)) + D * T(t) ./ diff(T(t),t)
? Which would simplify in part to (A+B+C)/diff(T(t),t) and then A+B+C, all being constants, could be replaced with the sum of the three?
When I see A/dt I tend to think you intend that A is a function of t and that you are expressing its derivative there, an operation that would more typically be expressed as dA/dt . But if that were the case then it is not clear why you would have a vector of constants for A.
Oday Shahadh
2017 年 2 月 22 日
sorry for making you miss understanding me, Dear Sir A,B and C varying with time, that have a value at each time step (t), and they are estimated previously, so for run time of(16000 second) I have the values of A,B and C for each time step, what you wrote is right (dA/dt)
T(t)=(dA/dt+dB/dt+dC/dt)+D(T/dt);
Oday Shahadh
2017 年 2 月 22 日
size(dA/dt) =(16000,1) and also dB/dt and dC/dt
Walter Roberson
2017 年 2 月 22 日
Are A, B, C intended to be tables to be linearly interpolated at the real times, along the lines of
this_A = interp1(times_A_was_sampled_at, A, t); %estimate at current time
? If so then there would be concern about whether the prior estimation and the interpolation would work together to produce values with continuous first derivatives; if not then you need to use a different approach because ode45() cannot support "jumps" at all.
Oday Shahadh
2017 年 2 月 23 日
編集済み: Walter Roberson
2017 年 2 月 23 日
Dear Walter, it is really difficult to me , but I tried this, insert a loop inside the ODE45, is it correct, also it going to be very slow
global : A B C
for i=1:10:t
Tdot=((A(i)+B(i)+C(i))-(T);
end
F1T=[Tdot];
end
Walter Roberson
2017 年 2 月 23 日
In your "for i" loop, you overwrite all of Tdot. The effect is going to be the same as if you had only done the last of the iterations.
You should avoid using global: global are the slowest form of variables. https://www.mathworks.com/help/matlab/math/parameterizing-functions.html
Oday Shahadh
2017 年 2 月 23 日
how to develope the loop? to avoid overwriting a previues values?
Walter Roberson
2017 年 2 月 23 日
i_vals = 1 : 10 : t;
num_i = length(i_vals);
Tdot = zeros(num_i, 1);
for i_idx = 1 : num_i
i = i_vals(i_idx);
Tdot(i_idx) = A(i) + B(i) + C(i) - T;
end
result = TDot;
Note that the resulting value changes length as t increases. If t represents the time parameter to the ode, then this would mean that you are trying to return a different number of derivatives as time goes on.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
