Can I call quadprog() using Embedded MATLAB from Simulink?

조회 수: 6 (최근 30일)
H S
H S 2011년 2월 9일
I've developed a Simulink model in which I need to perform a constrained quadratic minimization. I've tried placing a call to the Optimization Toolbox function quadprog in an Embedded MATLAB Function block but have encountered numerous errors. Is what I'm trying to do even allowable and, if so, what is the proper way to do it?

답변 (3개)

Kaustubha Govind
Kaustubha Govind 2011년 2월 9일
This is the list of functions supported with Embedded MATLAB.
If your function is not in this list, you can still call it using eml.extrinsic, but you cannot generate code from your model.

James Allison
James Allison 2011년 2월 16일
If you are fine with a simulation-only capability (i.e., no code generation), then you might also consider using a Level-2 MATLAB S-Function in place of EML. You can run quadprog from within the S-Function.

H S
H S 2011년 2월 9일
OK, I can live with only using quadprog() in simulation. However, the following code causes the error "Function output 'delUstar' cannot be of MATLAB type".
function delUstar = fcn(Phi, H, r, Rs, F, x)
eml.extrinsic('quadprog');
f = -2*Phi'*(Rs*r-F*x);
delUstar = quadprog(H,f,[],[]);
It seems that delUstar is of type mxArray and that some sort of conversion is necessary. Any suggestions on how to do this?
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2011년 2월 16일
Look for the 'Converting mxArrays to Known Types' section here: http://www.mathworks.com/help/toolbox/eml/ug/bq1h2z8-34.html#bq1h2z9-38

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by