Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to use 'fmincon' in hardware through simulink without any code generation error?

1 visualizzazione (ultimi 30 giorni)
Hello, I'm going to update a simulink program into hardware with a function 'fmincon', but there is one error about code generation, how can I solve it?
  2 Commenti
Walter Roberson
Walter Roberson il 13 Ago 2020
Modificato: Walter Roberson il 14 Ago 2020
Which release are you using?
The documentation indicates that you need MATLAB Coder, and Embedded Coder too for deploy to hardware. There are a number of other restrictions too such as only supporting sqp or Sqp-legacy.
Generally speaking, Simulink Coder does not support matlab functions that you need Coder.extrinsic for.
Jian Tian
Jian Tian il 14 Ago 2020
Thanks for your answer, I'm using MATLAB2018b. I have used 'coder extrinsic' in simulink to apply fmincon, and it worked well in only simulation process without hardware. But when deploying to hardware, the error occured.

Risposte (1)

Walter Roberson
Walter Roberson il 14 Ago 2020
Generally speaking, Simulink Coder does not support matlab functions that you need Coder.extrinsic for.
MATLAB Coder does support fmincon, under particular restrictions. As MATLAB Coder is a requirement to install Simulink Coder, then you can write your minimization code into a function, and use MATLAB Coder to generate C or C++ code for it. Then in your MATLAB Function Block, you can coder.ceval() the function you created -- or perhaps use a C Caller Block instead of MATLAB Function Block.

Community Treasure Hunt

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

Start Hunting!

Translated by