Is it possible to use 'trust-region' algorithm for the fsolve function inside a Simulink model?

2 ビュー (過去 30 日間)
Marco Pesenti
Marco Pesenti 2022 年 9 月 7 日
編集済み: Kartik 2023 年 2 月 21 日
I have a simulink model that contains a MATLAB function block. This matlab function block recalls the function fsolve, the optimization options chosen for the fsolve function are as follow:
options = optimoptions('fsolve','Display','none','Algorithm','levenberg-marquardt');
[S,fval,exit,output] = fsolve(f,S_0,options);
This works fine but i want to use for the algorithm value 'trust-region' instead of 'levenberg-marquardt', because it gives results that are more precise:
options = optimoptions('fsolve','Display','none','Algorithm','trust-region');
Trying to run my model in simulink with this line of code gives me this error:
OPTIMOPTIONS property 'Algorithm' must be one of the following values for fsolve:
'levenberg-marquardt'
Function 'resolve_S2.m' (#574.167.233), line 4, column 11: "optimoptions('fsolve','Display','none','Algorithm','trust-region')"
I should say that the MATLAB code works when not connected to the simulink environment with both options for the algorithm value, it only stops working when using the 'trust-region' option in simulink.
Is there a way to have the 'trust-region' option accepted by the simulink environment?

回答 (1 件)

Kartik
Kartik 2023 年 2 月 21 日
編集済み: Kartik 2023 年 2 月 21 日
Hi Marco,
As of R2022b, Simulink supports only 'levenberg-marquardt' algorithm for fsolve.
It is possible using coder.extrinsic, but then code generation is not possible.

カテゴリ

Help Center および File ExchangeManual Performance Optimization についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by