about Embedded matlab function

I want to use the 'find' function in simulink. How to do this function in the Embedded matlab function. for example I have a 6x1 array in simulink. I want to find over zero elements. How to do this?thx.

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2012년 2월 3일

0 개 추천

The 'find' function us listed amongst the functions supported for code-generation with added caveats for variable-size inputs. Are you seeing any errors?
A simple way of doing what you need is:
function y = fcn(u)
%#codegen
y = find(u>0);
Also, since 'y' is the output of the block and has a variable-size, you need to configure the port accordingly. On the Embedded MATLAB Fcn editor, select Tools>Edit Data/Ports. Select 'y' on the window, and on the right panel, check "Variable-size" and enter the upper bound of its size in the "Size: " text-box. In this case, 'y' cannot be larger than 'u', so you can enter [6 1], which is the size of your input.
FYI, you can also use the Find block in Simulink for this purpose.

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

질문:

2012년 2월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by