Clear Filters
Clear Filters

i am getting error in line 17

8 views (last 30 days)
Mukesh kumar Verma
Mukesh kumar Verma on 19 Apr 2018
Commented: KALYAN ACHARJYA on 21 Apr 2018
 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
Walter Roberson
Walter Roberson on 21 Apr 2018

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)

Guillaume
Guillaume on 20 Apr 2018

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

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!