Error: subscripted assignment dimension mismatch for loop
Mostrar comentarios más antiguos
Hello,
The error I get is :
subscripted assignment dimension mismatch at line 7
for j = 1:152
mhi_fig = sprintf('data%d.png', j);
img = imread(mhi_fig);
testFeatures(j,:) = extractHOGFeatures(img);
end
Why does this happen? and what is the solution?
Respuestas (1)
Image Analyst
el 2 de Mayo de 2015
0 votos
How many columns does testFeatures have? Does it have the same number of columns as the number of values that extractHOGFeatures() returns? It must. For example if extractHOGFeatures returns 4 numbers, then testFeatures must have 4 columns to take all those 4 values and put one value per column in row j.
2 comentarios
Andrew Tim
el 8 de Mayo de 2015
I have the same problem...the reason I understand but what is the solution? what matlab code should be in that case to assure that the number of columns is the same? thank you.
Walter Roberson
el 8 de Mayo de 2015
currentfeatures = extractHOGFeatures(img);
testFeatures(j, 1:length(currentfeatures)) = currentfeatures;
This code would silently expand the width of the testFeatures matrix if a file with more features was encountered, and will silently put in a smaller number of features if that is what is returned.
Basically the trigger for this problem is that images of different sizes are being read and the program has not been constructed to handle that.
Categorías
Más información sobre Computer Vision with Simulink en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!