hallo, i'm a beginner to matlab and i would appreciate your help.
matlab is showing an error at
The function 'fsolve' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
does this suggest that fsolve can't be used in simulink? are there other options, that would do a similar job and that can be used in simulink? i tried different modifications, but it didn't seem to help.
can anyone help me? best regards

 採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 7 月 5 日

2 投票

Perhaps the (Embedded) MATLAB Function block is not right for you, because FSOLVE is not supported for code-generation. If you're familiar with writing S-functions, writing a Level-2 MATLAB-file S-function might be better.
If you have to use this block, I would create a separate function on the MATLAB path that calls into FSOLVE and performs other operations unsupported for code-generation and call it from the (Embedded) MATLAB Function block using the code.extrinsic directive.

6 件のコメント

Bharat
Bharat 2015 年 2 月 7 日
is there any other way apart from creating S-Functions that i could go about to use fsolve and get code generation?
Anan Yaghmour
Anan Yaghmour 2021 年 10 月 12 日
編集済み: Anan Yaghmour 2021 年 10 月 12 日
you can use the MATLAB interpreted FCN block, and you don't need to implement the S-function for fsolve.
Amal Aljasmi
Amal Aljasmi 2022 年 2 月 24 日
@Kaustubha Govind, Interpreted Fcn block works while running the model but causes an error when you try to compile it. Is there any way to use fsolve in Simulink and also be able to compile it later? Thanks
Walter Roberson
Walter Roberson 2022 年 2 月 24 日
These days, code generation is supported for fsolve; https://www.mathworks.com/help/optim/ug/fsolve.html#mw_c671c5b5-f1b5-48de-bd68-e8bfa764994b . This might, however, require licenses beyond what you are using now.
Amal Aljasmi
Amal Aljasmi 2022 年 2 月 24 日
編集済み: Amal Aljasmi 2022 年 2 月 24 日
@Walter Roberson Thanks for a reply. Could you please clarify, to generate code for fsolve in Simulink we can use Interpreted MATLAB Fcn, as mentioned here https://uk.mathworks.com/matlabcentral/fileexchange/61633-fsolve-matlab-simulink-example , or MATLAB Function? Also, could you please provide a simple example of integration fsolve function in Simulink that's supported for later compiling. Thanks in advance.
Walter Roberson
Walter Roberson 2022 年 2 月 25 日
I have not done it myself, and I do not know if it can be done in any "simple" way. But it should at least be possible now.
It could potentially require putting in coder.ceval() statements to call routines that you generated code for using MATLAB Coder. Or perhaps there are easier ways.
I have rarely had reason to generate code from Simulink (and never on Windows), so I am fairly rusty on the practical details.

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

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by