how to remove this error?

1 view (last 30 days)
maida
maida on 10 Dec 2016
Commented: maida on 10 Dec 2016
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

Accepted Answer

Image Analyst
Image Analyst on 10 Dec 2016
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 Comment
maida
maida on 10 Dec 2016
Error using reshape To RESHAPE the number of elements must not change.
Error in mathworks (line 18)
fv= reshape(fv,1,262144);

Sign in to comment.

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!