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.

Risposte (1)

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.

Categorie

Scopri di più su Simulink Coder in Centro assistenza e File Exchange

Richiesto:

il 1 Feb 2012

Community Treasure Hunt

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

Start Hunting!

Translated by