how to remove this error?

1 回表示 (過去 30 日間)
maida
maida 2016 年 12 月 10 日
コメント済み: maida 2016 年 12 月 10 日
1.i have 50 images
2.my code produces feature vector of size 512 by 512 of 50 images using a for loop
3. i am using reshape function to make matrix of 512 by 512 into 1 by 512*512=262144 vector. similarly for 50 images i need to do the same to get the final mat file of dimension 50 rows and 262144 columns.
4. whenever i try to save this vector. i always get this error
Subscripted assignment dimension mismatch.
Error in mathworks (line 19)
Result(i,:) = fv;
4. fv is producing a mat file containing 1 by 262144 feature vectors.As error occur during the first image(am using for loop to do the same process for all 50 images)
5. The code is attached please tell me the problem

採用された回答

Image Analyst
Image Analyst 2016 年 12 月 10 日
You have this line:
fv= reshape(fv,i,[]);
This reshapes fv to have 1 row and 262144 rows when i=1, and 2 rows and 262144/2=131077 the second iteration when i=2. So now fv is not a vector anymore but a matrix of size 2 rows by 131077 columns. You can't stick a matrix into an array where you're specifically specifying that the data should go ONLY into columns like this:
Results(i,:) = fv;
If you want fv to be a row vector of 262144 columns, then you need to do this:
fv = reshape(fv, 1, 262144);
  1 件のコメント
maida
maida 2016 年 12 月 10 日
Error using reshape To RESHAPE the number of elements must not change.
Error in mathworks (line 18)
fv= reshape(fv,1,262144);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by