MATLAB: I am getting error index exceeds matix dimension in line 23

image processingMATLAB

RGB =imread('image.jpg');
hsv= rgb2hsv(RGB);
imshow(hsv);
r1=0.1;
r2=0.85;
i= 0:20:240;
s= 0.0:0.2:1.0;
wgray = 1 - bsxfun(@power, s(:),(r1*(255./(i(:).')).^r2) );
P= gradient(wgray,0.2);
Q= gradient(wgray,0.4);
R= gradient(wgray,0.6);
S= gradient(wgray,0.8);
T= gradient(wgray,1.0);
bar(i,P');
a=imread('benign.png');
level = graythresh(a);
BW = im2bw(a,level);
imshow(BW);
Area= bwarea(BW);
Mean= mean2(BW);
std = std2(BW);
E= entropy(BW);
Var = var(BW(:));
Thanks….

Best Answer

You probably created a variable name "var" but now you want to use var() as a function. When you create a variable with a particular name, you can no longer use the function with the same name as the variable until the variable with that name is deleted.
Related Question