Error: subscripted assignment dimension mismatch for loop
이전 댓글 표시
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?
답변 (1개)
Image Analyst
2015년 5월 2일
0 개 추천
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
Andrew Tim
2015년 5월 8일
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
2015년 5월 8일
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.
카테고리
도움말 센터 및 File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!