Thread Subject:
Reshaping Cells

Subject: Reshaping Cells

From: james bejon

Date: 1 Apr, 2010 02:07:07

Message: 1 of 3

Does anyone know of a way of reshaping cells? That is, suppose I have a {10 x 5} cell array of strings and I want to make it a {1 x 5} cell array of {10 x 1} cell arrays. Is there a nice way of doing this?

Subject: Reshaping Cells

From: Walter Roberson

Date: 1 Apr, 2010 02:27:47

Message: 2 of 3

james bejon wrote:
> Does anyone know of a way of reshaping cells? That is, suppose I have a
> {10 x 5} cell array of strings and I want to make it a {1 x 5} cell
> array of {10 x 1} cell arrays. Is there a nice way of doing this?

I think this should work:

arrayfun(@(idx) B(:,idx), 1:size(B,2), 'Uniform', 0);


You are not really asking for "reshape", as you are changing the nesting
level of the data.

Subject: Reshaping Cells

From: james bejon

Date: 1 Apr, 2010 12:14:04

Message: 3 of 3

That's exactly what I was after. Thanks. By the way, how does the syntax/logic work with arrayfun? I couldn't find much about what you're doing with it in the function browser. It's just letting you use (idx) as a variable to loop through the array, right?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
strings james bejon 31 Mar, 2010 22:09:07
cell james bejon 31 Mar, 2010 22:09:07
array james bejon 31 Mar, 2010 22:09:07
reshape james bejon 31 Mar, 2010 22:09:06
rssFeed for this Thread

Contact us