why i m getting this error "Array indices must be positive integers or logical values. or min=min(dist);" please help me out?

1 visualizzazione (ultimi 30 giorni)
%% 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<3)
m=find(dist==min,1);
det_class=cstrain(m);
msgbox(strcat('dectected class',num2str(det_class)));
else
msgbox('This person is not register');
end

Risposta accettata

Steven Lord
Steven Lord il 19 Giu 2020
You cannot call the min function while a variable named min exists in the workspace. Rename or remove the variable.
  3 Commenti
madhan ravi
madhan ravi il 19 Giu 2020
I should have stuck to that explanation as always xD, thought could do something different this time but lead to confusions.

Accedi per commentare.

Più risposte (1)

madhan ravi
madhan ravi il 19 Giu 2020
Modificato: madhan ravi il 19 Giu 2020
clear all % at the very beginning, this clears the variable named ‘min’
MIN = min(dist); % change your line to this, means u have to change all the min variable to MIN , naming a variable min is a bad idea which shadows the inbuilt function min(...)
  3 Commenti
Deepak Yadav
Deepak Yadav il 19 Giu 2020
%% 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(:,4);
for(i=1:size(Ftrain,1))
dist(1,:)=sum(abs(Ftrain(1,:)-Ftest));
end
m=find(dist==min(dist),1);
det_class=ctrain(m);
this is my code .........in database their is three variety of face which is classified into two class . so when i am giving class 1 input then it show "deteced class 1 " but when i m giving class 2 picture then it show again same Answer .....please help me .... i will send u whole code if u want.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by