Size mismatch error using regionprops in Simulink matlab function block

4 views (last 30 days)
I am trying to use matlab's regionprop function in a matlab function block in Simulink. In the function block, I have a 47 x 52 binary image (BW) and I want to use regionprops to extract various properties. Below is my code to extract the centroids of the binary image. When I run the simulink model I get the following error:
"Size mismatch for MATLAB expression 'regionprops'. Expected = 1x1 Actual = 7x1"
I suspect this is because I have 7 different centroids, but I am unsure of how to get around this error.
coder.extrinsic('regionprops')
s_centroid = struct('centroid', zeros(2,1));
s_centroid = regionprops(BW, 'centroid');
centroid = s_centroid.centroid

Answers (0)

Community Treasure Hunt

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

Start Hunting!