Undefined function or variable

3 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Zernike Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!