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