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

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Manual Performance Optimization 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by