Subscripted assignment dimension mismatch.

Hi there,
I'm writing a piece of code for facial recognition and i am getting the error message 'Subscripted assignment dimension mismatch.' on a certain section of the code;
faceDatabaseFeatures = zeros(size(faceDatabase,2)*faceDatabase(2).Count,4280);
featureCount = 1;
for i=1:size(faceDatabase,2)
for j = 1:faceDatabase(i).Count
faceDatabaseFeatures(featureCount,:) = extractHOGFeatures(read(faceDatabase(i),j));
faceDatabaseLabel{featureCount} = faceDatabase(i).Description;
featureCount = featureCount + 1;
end
personIndex{i} = faceDatabase(i).Description;
end
Under
faceDatabaseFeatures(featureCount,:) = extractHOGFeatures(read(faceDatabase(i),j));
I believe it is here that the problem is occuring but i cannot for the life of me see why it is giving me that error.
This is the image of my workspace, any help would be much apperciated.
Andrew

7 Commenti

Adam
Adam il 10 Gen 2019
Modificato: Adam il 10 Gen 2019
This error comes from an assignment operation in which the size of the thing you are trying to assign is different to (incompatible with) that of the thing you are trying to assign it to.
In your case this almost certainly comes on this line:
faceDatabaseFeatures(featureCount,:) = extractHOGFeatures(read(faceDatabase(i),j));
where the size of the result being returned by extractHOGFeatures is not the same as the size of faceDatabaseFeatures(featureCount,:), which appears to be (1,4280)
If you use the Stop on errors option for debugging then it will halt the code at the occurence of this error and you can easily look at
size( extractHOGFeatures(read(faceDatabase(i),j)))
and
size( faceDatabaseFeatures(featureCount,:) )
on the command line to see what is happening.
You're a star! this worked perfectly. Thank you for your well presented answer!
I have another question if you do not mind answering it.
I am currently now getting this error message;
Error using subsindex
Function 'subsindex' is not defined for values of class 'imageSet'.
I have no idea what it means even reading the help section has not given me any more knowledge on how to stop this error because i'm not using the 'subsindex' in my work.
Thanks in advance,
Andrew
Which code line causes the error? subsindex is called implicitly when you index an array.
It doesnt state where the issue is coming from it just says theres an issue with imageSet but i am now also getting this error message;
Error using subsindex
Function 'subsindex' is not defined for values of class 'imageSet'.
Error in MATLABCW (line 91)
queryImage = sample(sample(person),j);
my imageSet code is;
faceDatabase = imageSet('NewMATLAB','recursive');
Thanks
What does
which -all imageSet
show on that line if you put a breakpoint on that line and put the above on the command line?
C:\Program Files\MATLAB\R2015a\toolbox\vision\vision\imageSet.m % imageSet constructor

Accedi per commentare.

Risposte (1)

Jan
Jan il 11 Gen 2019
Modificato: Jan il 11 Gen 2019
I looks like it does show, which line is failing:
queryImage = sample(sample(person),j);
Use the debugger to examine the problem. Type this in the command window:
dbstop if error
Now run the code again. When it stops at this line, try this:
person
sample(person)
j
sample(sample(person),j)
What do you observe?

1 Commento

I still get this error when doing that;
Error using subsindex
Function 'subsindex' is not defined for values of class 'imageSet'

Accedi per commentare.

Categorie

Prodotti

Release

R2015a

Richiesto:

il 10 Gen 2019

Commentato:

il 11 Gen 2019

Community Treasure Hunt

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

Start Hunting!

Translated by