Undefined function or variable 'm'
이전 댓글 표시
I'm newer using matlab I wrote this code,but i have a error Plz help me,thanks
A=imread('21_training.tif');
B=A(:,:,2);
%opening disk = 3
se=strel('disk',3);
C=imopen(B,se);
%co-occurrence matrix
glcm=graycomatrix(C,'NumLevel',256);
p=glcm/sum(glcm(:));
%mean pi,pj and standard deviation pi,pj (mean pi=mean pj)
for i=1:256
for j=1:256
m=m+double(i).*p(i,j);
end
end
error: Undefined function or variable 'm'
채택된 답변
추가 답변 (2개)
Azzi Abdelmalek
2013년 11월 8일
편집: Azzi Abdelmalek
2013년 11월 8일
The for loop
m=0
for i=1:256
for j=1:256
m=m+double(i).*p(i,j);
end
end
can be replaced by
m=sum(sum(repmat((1:256)',1,256).*p))
%or
m=sum(sum(bsxfun(@(x,y) x.*y,p,(1:256)')));
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!