MATLAB Answers

0

Hi, This is my code.[fname path]=uige​tfile('.jp​g','open a image as input for trining'); fname=strc​at(path,fn​ame); im=imread(fname); imshow(im); title('Input Image'); c=input('Enter the Class (Numbers from 1-10)'); %%Feature extraction F=FeatureStatis

Asked by Samadhi Hirimuthugoda on 16 Sep 2018 at 13:14
Latest activity Commented on by Image Analyst
on 16 Sep 2018 at 14:38

c=input('Enter the Class (Numbers from 1-10)') in here I want to put the image class in string characters. how can I do it insted of numbers.

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 16 Sep 2018 at 13:58
 Accepted Answer

To get your number as a string instead of a double, use the 's' option:

classNumber = input('Enter the class number : ','s')

  2 Comments

Thank you very much. This is my first math lab program. When I move to the testing step I got an error.

"Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."

My code is this.

[fname path]=uigetfile('.jpg','Provide a Image for Testing');
fname=strcat(path,fname);
im=imread(fname);
imshow(im);
title('Test Image');
%% Find out which class it belongs
Ftest=FeatureStatistical(im);
%% Compare with database
load db.mat
Ftrain=db(:,1,2);
Ctrain=db(:,3);
for{1=1:size{Ftrain,1}}
dist{1,:}=aum(aba{Ftrain{1,:}-Ftest});
end
m=find(dist==min(dist),1);
det_class=Ctrain(m);
msgbox(strcat('detected class=',num2str(det_class)));

And the error gives for this.

for{1=1:size{Ftrain,1}}

If you can please help me

Don't use braces. Try this:

for k = 1 : size(Ftrain,1)
	dist{1,:} = aum(aba(Ftrain{1,:}-Ftest));
end

but I'm not sure what your variables are. Use braces only with cell arrays and tables. See the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

Sign in to comment.