MATLAB function in External mode
조회 수: 1 (최근 30일)
이전 댓글 표시
I work on TI C2000 in external mode, in the model I'm running on the target I have MATLAB function in the Simulink model, is there any particular settings for this function to perform on the target in the same way it works in Simulink in normal mode?
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 8월 13일
If you have MATLAB Coder and Simulink Coder then for a restricted set of routines, C or C++ code can be generated for use on the C2000. You need to use a MATLAB Function Block (I believe). You will need to rewrite the code in some ways. One of the parts that is needed most often is to declare the size of the variables, as C is not as flexible about dynamic sizing of variables (and also because when you are on an embedded processor you need certainty about the maximum memory used.) See http://www.mathworks.com/help/fixedpoint/ug/defining-variable-size-data-for-code-generation.html
Coder will try to determine the size of the outputs based upon the code. However if you call any MATLAB routines, it may not be able to predict the size that is going to be returned. For this reason if your output depends upon calling a MATLAB routine, it is important that you add an extra assignment statement before the real assignment, where the assignment statement assigns an explicit size to the variable. For example,
y = zeros(1,u(3),'single'); %assign something of an obvious size!
y = sin(single(linspace(u(1), u(2), u(3)))); %then you can assign something where the size is not as clear
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!