[S.Area] not supported for code generation
显示 更早的评论
hey guides i use this function on the simulink but show the error:Referencing a component from array of non-scalar values is not supported for code generation.
Function 'MATLAB Function' (#35.204.212), line 8, column 25:
"[S.Area]"
Launch diagnostic report.
what can replace this to success simulation on simulink.
function y = areaimg(u)
bw2 = zeros(240,320);
ss = 20;
B = 6000;
img_bw2 = bwareaopen(u,ss,8);
[L2,num2]=bwlabel(img_bw2,8);
S = regionprops(L2,'Area');
bw2 = ismember(L2, find([S.Area] < B));
y = bw2;
end
采纳的回答
更多回答(2 个)
Image Analyst
2017-10-27
0 个投票
What is num2? Is it 0, and therefore S is empty? If S is empty, then trying to access S.Area would throw an error.
Image Analyst
2017-10-27
The whole function can be done with this single line of code
y = bwareafilt(u, [1, 6000]);
类别
在 帮助中心 和 File Exchange 中查找有关 Foundation and Custom Domains 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!