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

2 views (last 30 days)
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?

Answers (1)

Kartik
Kartik on 21 Feb 2023
Edited: Kartik on 21 Feb 2023
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.

Categories

Find more on Manual Performance Optimization in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!