Comments on: Reshape a matrix without using a for loop https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/?s_tid=feedtopost Stuart uses video to share his experiences solving problems with MATLAB day-to-day, interesting new features, plus tips and tricks he has picked up along the way. Thu, 21 Mar 2019 16:26:18 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Doug https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2963 Tue, 10 Jan 2012 20:34:53 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2963 Vishnu,

There is no randomness in reshape. It is deterministic, and will always give the same results for the same inputs.

Doug

]]>
By: Vishnu https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2961 Sun, 08 Jan 2012 22:39:04 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2961 Doug, I have a quick question, the answer to which I couldn’t find anywhere. Does reshape work the exact same way each time you do it? For example, I want to reshape a 3D matrix to a single vector. However, each dimension means something to me and I need to do this for many 3D matrices and want the entries in the final vector to correspond to the same dimensions. So does reshape go through the 3D matrix in the same order every time I reshape a 3D matrix? Sorry if this is a dumb question.. I’m a matlab beginner. Thanks for your time!

]]>
By: dan https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2789 Wed, 21 Sep 2011 06:08:57 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2789 Hi, sorry to bother you i think i got it. Thank you for you wonderful tips!

]]>
By: dan https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2788 Wed, 21 Sep 2011 05:52:38 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2788 Do you mean this?

a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
b = transpose(a);
c = reshape(b,2,10)

I still get the up and down result. Sorry I’m very new to matlab. Hope you can help.Many many thanks in advance.

]]>
By: dhull https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2787 Tue, 20 Sep 2011 19:18:09 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2787 @dan,

Transpose it first, then reshape.

Doug

]]>
By: dan https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2786 Tue, 20 Sep 2011 15:49:56 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2786 hello lets say i have
a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
instead of reshape it up n down which will result to this
1 3 5 7 9 11 13 15 17 19
2 4 6 8 10 12 14 16 18 20

i want it to be like these
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20

is it possible? Thanks in advance.

]]>
By: dhull https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2770 Wed, 31 Aug 2011 15:59:52 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2770 Kwashie,

What does it even meant to do these operations? I can not understand what that would even look like.

Doug

]]>
By: Kwashie https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2768 Wed, 31 Aug 2011 12:26:57 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2768 I have a 1 x 6 matrix which i need to add to a 1 x 12 matrix after which i have to multiply by a 1 x 18 matrix. Can you please guve me an idea on how i con do that. Thanks

]]>
By: dhull https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2434 Mon, 08 Nov 2010 16:32:59 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2434 @Jerry,

There might be some clever way to do this without for loops, but it would be confusing and non-intuitive. Just use a clear and easy loop to do this.

Doug

]]>
By: Jerry https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2416 Fri, 05 Nov 2010 21:20:19 +0000 https://blogs.mathworks.com/videos/2009/03/13/reshape-a-matrix-without-using-a-for-loop/#comment-2416 Hi Doug,

I also have a question about row-wise transformation.
suppose a=[ 1 2 3 4; 5 6 7 8], if I want to get
b=[1 2; 5 6; 3 4; 7 8]. Is there a simple way of using reshape without for loop? Thanks in advance.

Jerry

]]>