Borrar filtros
Borrar filtros

Undefined function or variable

3 visualizaciones (últimos 30 días)
tsai kai shung
tsai kai shung el 26 de Oct. de 2017
Comentada: tsai kai shung el 26 de Oct. de 2017
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!

Respuesta aceptada

Jan
Jan el 26 de Oct. de 2017
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

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!