clc;
clear all;
close all;
[fname path]=uigetfile('.jpg','Open a face as input for Training');
fname=strcat(path,fname);
im=imread(fname);
imshow(im);
title('input face');
c=input('Enter the class(Number from 1-10)');
 F=Featurestatistical(im);
try
     load db;
     F=[F c];
     db=[db;F];
     save db.mat db
catch
     db=[F c];
     save db.mat db
end    

6 commentaires

Image Analyst
Image Analyst le 19 Avr 2018
Do you have a question? I mean other than how to format code, which can be answered here: http://www.mathworks.com/matlabcentral/answers/13205#answer_18099 Also give us the error - ALL the red text, all of it.
Mukesh kumar Verma
Mukesh kumar Verma le 20 Avr 2018
Well there is no problem with format.....actually this code is showing error in dB=[F C]; after catch......there seems no problem with code the problem may be with the image format which is also jpg but is 100×100× 3uigt something showing on workspace where 100×100 is size......it shows horzcat error...... How to fix it
Walter Roberson
Walter Roberson le 20 Avr 2018
What is size(F)?
Mukesh kumar Verma
Mukesh kumar Verma le 21 Avr 2018
F is a function with value F=[m s] m is mean and s is varience.......

F cannot be a function. You are doing

 F=[F c];

which replaces the previous value of F with the results of concatenation of F and a scalar value. You cannot concatenate a function handle and a numeric scalar value.

db=[F;c];

Connectez-vous pour commenter.

Réponses (1)

Guillaume
Guillaume le 20 Avr 2018

1 vote

it shows horzcat error

[F c] can only work if F and c have the same number of rows. Clearly, since you're getting an error they haven't. We can't tell you what the fix is since we have no idea why you're trying to concatenate these two together.

Note that since c is a result of user input, it can have an arbitrary number of rows. If the user types 10 at the prompt, then c will have one row. If the user types [1;2;3] at the prompt then c will have three rows. Therefore, it's very easy for the user to break your code. After getting the user input, you should check that that inputs conforms to whatever you expect. E.g. if you expect the user to enter just a single value, you should have:

assert(isscalar(c), 'Input must be scalar');

after your input line.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by