Code generation for "quadprog"

Hi, I am trying to get code generation for "quadprog", I am getting error message "Function 'optimoptions' not supported for code generation". I am using MATLAB2018b. What might be the possible solutions?

 Accepted Answer

Ameer Hamza
Ameer Hamza on 11 Nov 2020
Code generation for optimoptions is only enabled in R2020b, and for quadprog(), it was enabled in R2020a. There is no way to get it in R2018b.

13 Comments

I am glad to be of help!
I want to ask why I upgrade matlab to 2020, but still report an error to show that this function cannot generate code?
Did you upgrade to release R2020a or release R2020b?
Upgrade 2020b, and I read the quadprog document. It's different from the previous version. It does have an extension function, which is to generate C code, but there are several restrictions. Then I modify the code one by one according to the conditions, basically meeting the requirements. I do hardware in the loop simulation, and need to compile to generate code. However, because this function compiles, it will still report an error. The error is as follows
The extrinsic function 'quadprog' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'quadprog' or by ensuring that its outputs are unused.
Can you run the example Generate Code for quadprog? If not, then I suggest that you contact technical support. If so, then the fault is somewhere else in your code, because quadprog is supported.
According to the release notes, quadprog has been supported for code generation since R2020a.
Alan Weiss
MATLAB mathematical toolbox documentation
Later I ran this example and found the problem. Matlab did not find a supported compiler. Then I downloaded the MinGW-w64 C/C++ compiler. I ran this example successfully, but my hardware device supports VS software. , I downloaded VS2015 on my computer before, but why the VS compiler cannot be displayed when MATLAB runs the mex -setup command? I reinstalled VS2017 and MATLAB2020, but still can’t find the compiler. How can I solve this problem ?
Now matlab (2020b) has found a supported compiler (vs2017), but I still report an error in the process of compiling the model (The extrinsic function 'quadprog' is not available for standalone code generation). Previously, I used MinGW compiler to try to generate code for quadprog test cases, but the hardware in the loop simulation I did only supports vs compiler, so how can I solve this problem?
The above two figures are the established Simulink model and the self-defined AdaptiveMPC function in the model. There is a quadratic programming solving function quadprog in the function. The error is that this function cannot generate code.
Just now, it is OK to generate the test example of Quadlog function with vs2017 compiler. However, compiling my model will report the error that the Quadlog function cannot generate code.
Dear li, has your hardware in the loop simulation with quadprog been implemented.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!