MATLAB: ??? Subscript indices must either be real positive integers or logicals.

errorxlswrite

I got problem with my code anybody can help..went i run the error is ??? Subscript indices must either be real positive integers or logicals.
Error in ==> forloop at 12 M=mean(H); % mean
filename='trainingData.xls';
srcFiles = dir('D:\MASTER\MATLAB\dataset\training\text\*.jpg'); % the folder in which ur images exists
for ii = 1 : length(srcFiles)
filenames = strcat('D:\MASTER\MATLAB\dataset\training\text\',srcFiles(ii).name);
I = imread(filenames);
im=imresize(I, [300,300]);
H=hog_feature_vector(im);
% add more statistical functions
M=mean(H); % mean
S=std(H); % standard deviation
E=norm(H,2)^2; % the energy
En=entropy(H); % entropy
C=corrcoef(H); % correlation
Img=filenames; mn=M; sd=S; engy=E; ent=En; corr=C;
fileExist=exist(filename,'file');
if fileExist == 0
header ={'Image','Mean','Std','Energy','Entropy','Correlation'};
xlswrite(filename,header);
else
[~,~,input]=xlsread(filename);
new_data={img,mn,sd,engy,ent,corr};
output=cat(1,input,new_data);
xlswrite(filename,output);
end
end

Best Answer

In your case, you almost certainly have an array called mean(). You're intending to use the function mean, but you blew it away by creating an array called mean and it's thinking H is supposed to be the index(es) of that array, which of course it's not. Try this
which -all mean