Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
help with reshape statement

Subject: help with reshape statement

From: aralimaradsir@gmail.com

Date: 6 Jun, 2009 04:31:21

Message: 1 of 4

i used statement reshape in my program and it is giving the error as
below
??? Error using ==> reshape
To RESHAPE the number of elements must not change.


what could be the resons for this i cant put my code here its too
lenghtier.so can anyone help me how remove this error.thank you.

Subject: help with reshape statement

From: Matt Fig

Date: 6 Jun, 2009 05:00:17

Message: 2 of 4

aralimaradsir@gmail.com wrote in message <9a7cf4b3-7ecb-4737-8184-2a8457c9b3ab@r3g2000vbp.googlegroups.com>...
> i used statement reshape in my program and it is giving the error as
> below
> ??? Error using ==> reshape
> To RESHAPE the number of elements must not change.
>
>
> what could be the resons for this i cant put my code here its too
> lenghtier.so can anyone help me how remove this error.thank you.


Surprisingly, the reasons for this error are exactly what the error says. Say you have a 2-by-2 matrix, which will of course have 4 elements. Now if you try to make it a 3-by-1 vector, which has 3 elements, the number of elements will need to change.

The reshape function will not allow this.

On a 2-by-2, you could reshape to:

4-by-1
1-by-4
2-by-2 (silly, but true)

Notice that all choices have 4 elements, like the original 2-by-2 matrix.

Subject: help with reshape statement

From: John D'Errico

Date: 6 Jun, 2009 11:02:01

Message: 3 of 4

aralimaradsir@gmail.com wrote in message <9a7cf4b3-7ecb-4737-8184-2a8457c9b3ab@r3g2000vbp.googlegroups.com>...
> i used statement reshape in my program and it is giving the error as
> below
> ??? Error using ==> reshape
> To RESHAPE the number of elements must not change.
>
>
> what could be the resons for this i cant put my code here its too
> lenghtier.so can anyone help me how remove this error.thank you.

When you try to use reshape and get this error
it may indicate a mistake on your part. However,
I do occasionally want to change both the shape
and size of an array in one step. For this reason
I wrote wreshape.

wreshape allows you to expand or contract the
size of an array in the reshape step. When the
new size is smaller, it tales only the elements
that it needs. When the array must be expanded,
it allows you to specify what the new elements
will be, either as padding with a given value, or
by a circular padding, re-using the original
elements of your array.

Find wreshape on the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/23974

HTH,
John

Subject: help with reshape statement

From: Muhammad Imran

Date: 16 Jul, 2012 04:58:13

Message: 4 of 4

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h0dib9$7ne$1@fred.mathworks.com>...
> aralimaradsir@gmail.com wrote in message <9a7cf4b3-7ecb-4737-8184-2a8457c9b3ab@r3g2000vbp.googlegroups.com>...
> > i used statement reshape in my program and it is giving the error as
> > below
> > ??? Error using ==> reshape
> > To RESHAPE the number of elements must not change.
> >
> >
> > what could be the resons for this i cant put my code here its too
> > lenghtier.so can anyone help me how remove this error.thank you.
>
> When you try to use reshape and get this error
> it may indicate a mistake on your part. However,
> I do occasionally want to change both the shape
> and size of an array in one step. For this reason
> I wrote wreshape.
>
> wreshape allows you to expand or contract the
> size of an array in the reshape step. When the
> new size is smaller, it tales only the elements
> that it needs. When the array must be expanded,
> it allows you to specify what the new elements
> will be, either as padding with a given value, or
> by a circular padding, re-using the original
> elements of your array.
>
> Find wreshape on the file exchange.
>
> http://www.mathworks.com/matlabcentral/fileexchange/23974
>
> HTH,
> John
There is no file on this link if any body have this Wreshape function please upload it or email me at malikimran110@gmail.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us