How to deal with matlab functions that are unsupported when using Matlab Coder? (How can I transfer Matlab intrinsic function 'quadprog()' into C code using Matlab Coder?)
95 views (last 30 days)
I write a matlab function to realize some algorithm. When I use Matlab Coder to convert it into C code, it build failed with the following error:
The function 'quadprog' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
error code is: Optimal=quadprog(H,f);
In fact, I want to know how to deal with matlab functions that are unsupported when using Matlab Coder.
Thanks for helping me.
Kaustubha Govind on 9 Jan 2013
You can only generate standalone C/C++ code from functions supported for code-generation. You may either need to write your own C implementation for the function, or use MATLAB Compiler to deploy your MATLAB code. The code generated by MATLAB Compiler is not completely standalone (like that generated by MATLAB Coder), but depends on MATLAB run-time libraries, and therefore requires that each target machine either have the same version of MATLAB installed or have the corresponding version of the MATLAB Compiler Runtime installed.
Mary Fenelon on 21 Apr 2020
Code generation for quadprog is supported as of R2020a. Support for fmincon was added in R2019b.
Fred Smith on 10 Jan 2013
If you don't really need C code but are just running the function in MATLAB , you can often use CODER.EXTRINSIC to call the original MATLAB version. This probably won't work for QUADPROG since it probably takes a function handle as an argument. Function handles are not supported in extrinsic calls but almost everything else is.
If you really need C code because you are running in an environment that MATLAB natively does not support, then you can either write your own MATLAB implementation of the missing functionality, or use coder.ceval to bring in external C code that implements the functionality.
If you don't need C code and but do need to deploy your algorithm on a MATLAB-supported host, you can use MATLAB Compiler.