How to use linprog in Simulink?
이전 댓글 표시
I am running a co-simulation using Adams and Simulink. As a part of this procedure, I need to optimize a few variables. I used the 'Matlab Function Box' to write the requisite code. However it is not compiling. I get the following error. 'The function 'linprog' is not supported for standalone code generation. ' I got the same error using both linprog and fmincon.
Please help me resolve this. My work is stuck because of this problem. Thank you.
답변 (1개)
Zack Peters
2013년 10월 24일
2 개 추천
Hi Avinash,
Currently, both LINPROG and FMINCON are not supported for code generation. What is going on is that all of the code within your "MATLAB Function" block is being converted into a C S-function to create a more efficient simulation. To call functions that are not supported for code generation you can use the coder.extrinsic property to declare your function. Alternatively you can use the "Interpreted MATLAB Function" block which makes a call to the MATLAB engine and does not perform any sort of basic code generation. In either situation the result of a lack of code generation is a potentially slower simulation performance.
Additionally, both of the blocks listed above are going to be called at every time-step. This means that LINPROG or FMINCON could be run every time-step of your model. Is this what you really intend to do?
Here is a list of functions supported for code generation and information on the coder.extrinsic command.
~Zack
댓글 수: 2
Avinash Siravuru
2013년 10월 25일
Zack Peters
2013년 10월 25일
Hi Avinash,
I believe that you were on the right track with creating the trajectory offline. How important is the interpolation between two data points? The From File and From Workspace blocks will perform a linear interpolation on data.
If the interpolation is that important then I would either revisit the error you were getting with PPVAL (which as you noticed is not supported for code generation as of R2013b) or implement your own spline interpolation algorithm within handwritten MATLAB code.
~Zack
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!