Index exceeds matrix dimensions.

Error in ImageClassifier (line 11)
Ftrain=db(:,1,2);
Test Image
[fname,path]=uigetfile('.jpg','Provide a Image for Testing');
c=strcat(path,fname);
im=imread(fname);
imshow(im);
title('Test Image');
%% Fond out which Class it Belongs to
Ftest=FeatureStatistical(im);
%% Compare with Database
load db.mat
Ftrain=db(:,1,2);
ctrain=db(:,3);
for(i=1:size(Ftrain,1))
dist(1,:)=sum(abs(Ftrain(1,:)-Ftest));
end
Min=min(dist);
if(Min<50)
m=find(dist==Min,1);
det_class=ctrain(m);
msgbox(strcat('detected class',num2str(det_class)));
else
msgbox('Not Exist');
end

 采纳的回答

Torsten
Torsten 2018-12-11

0 个投票

"db" can not be a matrix of dimension 3 (db(:,1,2)) and of dimension 2 (db(:,3)) at the same time. Use "size" to get the dimension of "db".

更多回答(1 个)

Community Treasure Hunt

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

Start Hunting!

Translated by