Undefined function or variable
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponse acceptée
Jan
le 26 Oct 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Color Space Formatting and Conversions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!