i am getting error in line 17

 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 Comments

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.
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
What is size(F)?
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.

Sign in to comment.

Answers (1)

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.

Categories

Asked:

on 19 Apr 2018

Commented:

on 21 Apr 2018

Community Treasure Hunt

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

Start Hunting!