필터 지우기
필터 지우기

Undefined function or variable

조회 수: 3 (최근 30일)
tsai kai shung
tsai kai shung 2017년 10월 26일
댓글: tsai kai shung 2017년 10월 26일
function y = ratioimg(u)
[L2,num2]=bwlabel(u,8); %連通區域標記
B2=zeros(size(u));
for i=1:num2
[r,c] = find(L2==i);
left(i)=min(c);
right(i)=max(c);
up(i)=min(r);
down(i)=max(r);
if ((down(i)-up(i))/(right(i)-left(i)))>0.8&((down(i)-up(i))/(right(i)-left(i)))<1
[x,y]=find(L2==i);
B2=B2+bwselect(u,y,x,8);%%%把滿足長寬比在0.8到2的區域留下
end
end
y = B2;
end
i use this function on simulink simulation but show the error :
Undefined function or variable 'left'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#35.120.124), line 6, column 5:
"left"
Launch diagnostic report.
how can i solve this problem!

채택된 답변

Jan
Jan 2017년 10월 26일
You do not use left as a vector and it is not replied as output also. Then omit the "(i)":
function y = ratioimg(u)
[L2,num2] = bwlabel(u,8); %連通區域標記
y = zeros(size(u)); % Better than creating B2 and copy it to y
for i=1:num2
[r,c] = find(L2==i);
left = min(c);
right = max(c);
up = min(r);
down = max(r);
d = (down-up) / (right-left);
if d > 0.8 & d < 1
% [x,y]=find(L2==i); % Done above already
y = y + bwselect(u, c, r, 8); %%%把滿足長寬比在0.8到2的區域留下
end
end
end
  댓글 수: 1
tsai kai shung
tsai kai shung 2017년 10월 26일
Thank you for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color Space Formatting and Conversions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!