about Embedded matlab function
Show older comments
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.
Answers (1)
Kaustubha Govind
on 3 Feb 2012
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.
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!