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

 Accepted Answer

Torsten
Torsten on 11 Dec 2018
"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".

More Answers (1)

Ftrain=db(:,[1,2]);
^---^----square brackets

Asked:

on 11 Dec 2018

Answered:

on 11 Dec 2018

Community Treasure Hunt

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

Start Hunting!