Optimization toolbox with ode45

17 ビュー (過去 30 日間)
Alessia Nannetti
Alessia Nannetti 2021 年 3 月 15 日
コメント済み: Alan Weiss 2021 年 3 月 16 日
Thank you in advance for the help.
I want to use the optimization toolbox to find the correct value of v to get the condition that Y(end,2) = 0 instead of trying random v values in a for loop.
Does anyone has any suggestions in how can i do that?
here there is the code
v = [13:0.1:15]
for i=1:length(v)
u0 = (v(i)-ev-q*rd); %different values of pi_star at z=0
%having varied Pac
f = @(z,y) [-(a*y(2))./((1-(y(1)./(b*xi_star))).^3);... %dpi_star_dz
-y(1)/c]; %dq_star_dz
[z,Y] = ode45(f,[0 1],[u0 q_0]);
end

回答 (1 件)

Alan Weiss
Alan Weiss 2021 年 3 月 15 日
I guess that I would make a minimization problem for Y(end,2)^2. I don't know what your parameters are, but you can use fminbnd if you have a scalar parameter, or use lsqnonlin or one of the Global Optimization Toolbox solvers for multiple parameters.
  2 件のコメント
Alessia Nannetti
Alessia Nannetti 2021 年 3 月 15 日
the problem is that I want a specific value of v that returns me Y(end,2) = 0 (solution of the second equation of my sistem of odes).
v affects the value of u0 (which is one of my initial condition of the ode45).
I looked up your suggestions but my problem is that by knowing the minimum value (which is Y(end,2) = 0) find the correct value of v that affects the initial condition of my ode45 (u0)
Alan Weiss
Alan Weiss 2021 年 3 月 16 日
Maybe the question is "How can I connect an optimization solver and an ODE solver?" Here are some examples:
It is possible that you would want to use fzero as the optimization solver.
Alan Weiss
MATLAB mathematical toolbox documentation

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

カテゴリ

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