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:
Transposing columns to rows

Subject: Transposing columns to rows

From: Phoebe

Date: 28 Aug, 2012 14:07:09

Message: 1 of 5

Does anyone know if vast (~170,000) columns of data can be transposed to rows like =[1,2,3,4] within Matlab?
My data is currently in Excel but the limit on the number of columns restricts me transposing the data in Excel.

Subject: Transposing columns to rows

From: Matt J

Date: 28 Aug, 2012 14:14:06

Message: 2 of 5

"Phoebe " <phoebe_62@hotmail.co.uk> wrote in message <k1ijad$6l0$1@newscl01ah.mathworks.com>...
> Does anyone know if vast (~170,000) columns of data can be transposed to rows like =[1,2,3,4] within Matlab?
> My data is currently in Excel but the limit on the number of columns restricts me transposing the data in Excel.
====================

Like the following?

A=rand(4,170000);
tic; A.'; toc
%Elapsed time is 0.002088 seconds.

Subject: Transposing columns to rows

From: Phoebe

Date: 28 Aug, 2012 14:33:08

Message: 3 of 5

No as in i have columns

Type Length Width Depth
 0 14 140 3
 0 32 243 2
1 6 9 4

etc.
but i want to have it in matlab as
Type=[0,0,1...]
Length=[14,32,6...] and so on

There are too many entries to do so in Excel

Subject: Transposing columns to rows

From: Matt J

Date: 28 Aug, 2012 14:45:19

Message: 4 of 5

"Phoebe " <phoebe_62@hotmail.co.uk> wrote in message <k1ikr4$cp2$1@newscl01ah.mathworks.com>...
> No as in i have columns
>
> Type Length Width Depth
> 0 14 140 3
> 0 32 243 2
> 1 6 9 4
>
> etc.
> but i want to have it in matlab as
> Type=[0,0,1...]
> Length=[14,32,6...] and so on


I'm not seeing the difference between this and what I gave you. You mean the columns must not only be transposed, but assigned to separate variables (170000 of them)??

Subject: Transposing columns to rows

From: dpb

Date: 28 Aug, 2012 15:02:38

Message: 5 of 5

On 8/28/2012 9:33 AM, Phoebe wrote:
> No as in i have columns
>
> Type Length Width Depth
> 0 14 140 3
> 0 32 243 2
> 1 6 9 4
>
> etc. but i want to have it in matlab as
> Type=[0,0,1...]
> Length=[14,32,6...] and so on
>
> There are too many entries to do so in Excel

The orientation is no problem at all in Matlab as MattJ shows--if you're
implying to have 170k variable names, that's not "the Matlab way"--see
the FAQ on using cell arrays or more likely structure field names or
just use an array and direct indexing via a lookup of name to column
(now row) address.

<http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F>

--

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