splitting 1 large row into multiple rows

classic Classic list List threaded Threaded
6 messages Options
RT
Reply | Threaded
Open this post in threaded view
|

splitting 1 large row into multiple rows

RT

I have 1 large row with hundreds of columns in an array in octave

example of a row:  
540 6.28319 0 538.3 6.26573 0

I would like it to look like this. Every 3rd column move data to next row.

540 6.28319 0 
538.3 6.26573 0

How can I go about doing this? 

Thanks


--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: splitting 1 large row into multiple rows

Ron Crummett-2
Try reshape.
 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, 2, 3);

-Ron



On Mon, Oct 24, 2011 at 3:54 PM, Rick T <[hidden email]> wrote:

I have 1 large row with hundreds of columns in an array in octave

example of a row:  
540 6.28319 0 538.3 6.26573 0

I would like it to look like this. Every 3rd column move data to next row.

540 6.28319 0 
538.3 6.26573 0

How can I go about doing this? 

Thanks


--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
RT
Reply | Threaded
Open this post in threaded view
|

Re: splitting 1 large row into multiple rows

RT
Thanks for the quick response but that creates 
540 0 6.26573
6.28319 538.3 0

instead of (which I'm trying to get)
540 6.28319 0 
538.3 6.26573 0


I did try 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, [], 3); 
to get the other columns but it's just not giving me what I want which is 

540 6.28319 0 
538.3 6.26573 0

On Mon, Oct 24, 2011 at 1:05 PM, Ron Crummett <[hidden email]> wrote:
Try reshape.
 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, 2, 3);

-Ron



On Mon, Oct 24, 2011 at 3:54 PM, Rick T <[hidden email]> wrote:

I have 1 large row with hundreds of columns in an array in octave

example of a row:  
540 6.28319 0 538.3 6.26573 0

I would like it to look like this. Every 3rd column move data to next row.

540 6.28319 0 
538.3 6.26573 0

How can I go about doing this? 

Thanks


--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave





--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: splitting 1 large row into multiple rows

Ron Crummett-2
I was worried about that; I've got my system crunching data right now and so am relying on memory. Try
 
a = reshape(tmp, 3, 2)';
 
-Ron

On Mon, Oct 24, 2011 at 4:31 PM, Rick T <[hidden email]> wrote:
Thanks for the quick response but that creates 
540 0 6.26573
6.28319 538.3 0

instead of (which I'm trying to get)
540 6.28319 0 
538.3 6.26573 0

I did try 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, [], 3); 
to get the other columns but it's just not giving me what I want which is 
540 6.28319 0 
538.3 6.26573 0

On Mon, Oct 24, 2011 at 1:05 PM, Ron Crummett <[hidden email]> wrote:
Try reshape.
 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, 2, 3);

-Ron



On Mon, Oct 24, 2011 at 3:54 PM, Rick T <[hidden email]> wrote:

I have 1 large row with hundreds of columns in an array in octave

example of a row:  
540 6.28319 0 538.3 6.26573 0

I would like it to look like this. Every 3rd column move data to next row.

540 6.28319 0 
538.3 6.26573 0

How can I go about doing this? 

Thanks


--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave





--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: splitting 1 large row into multiple rows

Francesco Potortì
>I was worried about that; I've got my system crunching data right now and so
>am relying on memory. Try
>
>a = reshape(tmp, 3, 2)';

Yes, reshape fills the target matrix by column, so if you want it filled
by row, you should ask for three *rows* and then transpose the results:

octave> tmp = [540 6.28319 0 538.3 6.26573 0]

tmp =

   540.00000     6.28319     0.00000   538.30000     6.26573     0.00000

octave> a = reshape(tmp, 3, [])'

a =

   540.00000     6.28319     0.00000
   538.30000     6.26573     0.00000

--
Francesco Potortì (ricercatore)        Voice:  +39.050.315.3058 (op.2111)
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Fax:    +39.050.315.2040
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
RT
Reply | Threaded
Open this post in threaded view
|

Re: splitting 1 large row into multiple rows

RT
In reply to this post by Ron Crummett-2
thanks

On Mon, Oct 24, 2011 at 2:40 PM, Ron Crummett <[hidden email]> wrote:
I was worried about that; I've got my system crunching data right now and so am relying on memory. Try
 
a = reshape(tmp, 3, 2)';
 
-Ron

On Mon, Oct 24, 2011 at 4:31 PM, Rick T <[hidden email]> wrote:
Thanks for the quick response but that creates 
540 0 6.26573
6.28319 538.3 0

instead of (which I'm trying to get)
540 6.28319 0 
538.3 6.26573 0

I did try 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, [], 3); 
to get the other columns but it's just not giving me what I want which is 
540 6.28319 0 
538.3 6.26573 0

On Mon, Oct 24, 2011 at 1:05 PM, Ron Crummett <[hidden email]> wrote:
Try reshape.
 
tmp = [540 6.28319 0 538.3 6.26573 0];
a = reshape(tmp, 2, 3);

-Ron



On Mon, Oct 24, 2011 at 3:54 PM, Rick T <[hidden email]> wrote:

I have 1 large row with hundreds of columns in an array in octave

example of a row:  
540 6.28319 0 538.3 6.26573 0

I would like it to look like this. Every 3rd column move data to next row.

540 6.28319 0 
538.3 6.26573 0

How can I go about doing this? 

Thanks


--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave





--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave





--


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave