error is : Subscripted assignment dimension mismatch.

1 回表示 (過去 30 日間)
Ushna Asif
Ushna Asif 2015 年 11 月 14 日
回答済み: Dima Lisin 2015 年 11 月 23 日
this is my code for extraction of feature from folder having three sub folders but i am giving error at line trainingFeatures(featureCount,:)= ..... error is : Subscripted assignment dimension mismatch.
trainingFeatures = zeros(size(training,2)*training(1).Count,1008);
featureCount = 1;
for i=1:size(training,2)
for j = 1:training(i).Count
trainingFeatures(featureCount,:)= extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount} = training(i).Description;
featureCount = featureCount + 1;
end
personIndex{i} = training(i).Description;
end

採用された回答

Dima Lisin
Dima Lisin 2015 年 11 月 23 日
You may be getting this error because there may be different numbers of images in each imageSet. The easiest thing to do here is to make trainingFeatures a cell array.

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 11 月 14 日
You say size(training,2) indicating training is a 2D array, but then you later say training(i).Description indicating it's a 1-D array of structures. Before the loop, what does it say if you do this:
class training
whos training
size(training)
  2 件のコメント
Ushna Asif
Ushna Asif 2015 年 11 月 16 日
I'm getting this outputs
>>class training
ans =
char
>> whos training
Name Size Bytes Class Attributes
training 1x3 9682 imageSet
>> size(training)
ans =
1 3
Image Analyst
Image Analyst 2015 年 11 月 16 日
Sorry, I don't have the Computer Vision System Toolbox so I can't test anything with imageset variables. Perhaps Dima will answer.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by