Got Questions? Get Answers.
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:
Breaking Up Large Cell Array into Smaller Cell Arrays

Subject: Breaking Up Large Cell Array into Smaller Cell Arrays

From: Kevin Ellis

Date: 21 Aug, 2012 22:15:20

Message: 1 of 4

Hello,

I have a unique problem. Right now I have a large cell array and I want to break that cell array into smaller cell arrays. Here is a portion of the large cell array:

C =

              [1x35 char] [1x39 char] 'ALAMEDA' 'CA'
              [1x30 char] [1x20 char] 'ALAMEDA' 'CA'
              [1x30 char] [1x20 char] 'LUDINGTON' 'MI'
              [1x30 char] [1x20 char] 'LUDINGTON' 'MI'

Now, for this test case I want to break this into two smaller cell arrays according to the value in the third column. Here is where it gets difficult for me. I want to take the value 'ALAMEDA', make that a cell array, and fill it with all the entries that have 'ALAMEDA' in the third column. The problem I am facing is that I have to dynamically change variables names to value from the larger cell array C. The reason being is that the original cell array is 89492x17 cells, so I need to automate the process by having the program look for the change (in this case between 'ALAMEDA' and 'LUDINGTON') between variables and know to create a new variable name and fill the cell array.

I have tried to use eval, but that was unsuccessful. For me, this is pretty difficult and I would appreciate any help or guidance. My problem is unique, but I hope I explained it well enough here. Thanks.

Kevin

Subject: Breaking Up Large Cell Array into Smaller Cell Arrays

From: dpb

Date: 21 Aug, 2012 23:17:07

Message: 2 of 4

On 8/21/2012 5:15 PM, Kevin Ellis wrote:
> Hello,
>
> I have a unique problem. Right now I have a large cell array and I want
> to break that cell array into smaller cell arrays. Here is a portion of
> the large cell array:
>
> C =
> [1x35 char] [1x39 char] 'ALAMEDA' 'CA'
> [1x30 char] [1x20 char] 'ALAMEDA' 'CA'
> [1x30 char] [1x20 char] 'LUDINGTON' 'MI'
> [1x30 char] [1x20 char] 'LUDINGTON' 'MI'
>
> Now, for this test case I want to break this into two smaller cell
> arrays according to the value in the third column. Here is where it gets
> difficult for me. I want to take the value 'ALAMEDA', make that a cell
> array, and fill it with all the entries that have 'ALAMEDA' in the third
> column....

Don't do that; use structure w/ named field(s) instead...

--

Subject: Breaking Up Large Cell Array into Smaller Cell Arrays

From: Kevin Ellis

Date: 22 Aug, 2012 02:20:10

Message: 3 of 4

dpb <none@non.net> wrote in message <k114tj$dif$1@speranza.aioe.org>...
> On 8/21/2012 5:15 PM, Kevin Ellis wrote:
> > Hello,
> >
> > I have a unique problem. Right now I have a large cell array and I want
> > to break that cell array into smaller cell arrays. Here is a portion of
> > the large cell array:
> >
> > C =
> > [1x35 char] [1x39 char] 'ALAMEDA' 'CA'
> > [1x30 char] [1x20 char] 'ALAMEDA' 'CA'
> > [1x30 char] [1x20 char] 'LUDINGTON' 'MI'
> > [1x30 char] [1x20 char] 'LUDINGTON' 'MI'
> >
> > Now, for this test case I want to break this into two smaller cell
> > arrays according to the value in the third column. Here is where it gets
> > difficult for me. I want to take the value 'ALAMEDA', make that a cell
> > array, and fill it with all the entries that have 'ALAMEDA' in the third
> > column....
>
> Don't do that; use structure w/ named field(s) instead...
>
> --

I took a look at the help menu for structures. Still confused. I have never used structures before. How will that help me? It seems cell arrays are just as good.

Subject: Breaking Up Large Cell Array into Smaller Cell Arrays

From: dpb

Date: 22 Aug, 2012 03:02:38

Message: 4 of 4

On 8/21/2012 9:20 PM, Kevin Ellis wrote:
...


> I took a look at the help menu for structures. Still confused. I have
> never used structures before. How will that help me? It seems cell
> arrays are just as good.

Excepting you don't have to 'poof' variables into existence; you can
name the structures from string variables...

--

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