Error using reshape : number of elements must not change.

Hi there,
I am currently working on a communication system with a little of chaiotic cipher for greyscale images
but
I have a problem with reshape function ,
due to my little experience i don't know what is wrong or how to fix it
if you can help me fix it i would be thankfull
the project files:
images_chaotic_NOMA_2222222.m : line 56
error : Error using reshape
To RESHAPE the number of elements must not change.
Thanks in Advance.

 Accepted Answer

Read the documentation of reshape. The error is clear, you are trying to ressape an array with m*n elements to an array greater or less than m*n of elements. The number of elements in the reshaped array also shoould be m*n, if not you will gt same error.
A = rand(4,4) ;
B = reshape(A,8,2); % no error
C = reshape(A,2,8); % no error
D = reshape(A,5,3) ; % error, 15 < 16
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.

More Answers (0)

Categories

Products

Release

R2016a

Tags

Asked:

on 12 Nov 2021

Answered:

on 12 Nov 2021

Community Treasure Hunt

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

Start Hunting!