Thread Subject: cells delete empty entries

Subject: cells delete empty entries

From: Corinna Schmitt

Date: 18 Jan, 2008 14:27:01

Message: 1 of 4

Hallo,

I have the following problem with a cell construct:


hilfe =

  Columns 1 through 4

     [] [] 'IPF22252.1' 'IPF11815.2'

  Column 5 through 8

     'Contig4-2494_0015' [] 'CA1232' []

 Column 8

     []

Now I want to delete the empty cells. I tried it with the
command isempty in cooperation with an if-construct. But it
does not work.
My aim is such cell construct:

result =

  Columns 1 through 3

     'IPF22252.1' 'IPF11815.2' 'Contig4-2494_0015'
   

  Column 4

     'CA1232'

Thanks, Corinna

Subject: cells delete empty entries

From: Anh Huy Phan

Date: 18 Jan, 2008 14:41:02

Message: 2 of 4

"Corinna Schmitt" <csc@igb.fhg.de> wrote in message
<fmqcvl$5d7$1@fred.mathworks.com>...
> Hallo,
>
> I have the following problem with a cell construct:
>
>
> hilfe =
>
> Columns 1 through 4
>
> [] [] 'IPF22252.1' 'IPF11815.2'
>
> Column 5 through 8
>
> 'Contig4-2494_0015' [] 'CA1232' []
>
> Column 8
>
> []
>
> Now I want to delete the empty cells. I tried it with the
> command isempty in cooperation with an if-construct. But it
> does not work.
> My aim is such cell construct:
>
> result =
>
> Columns 1 through 3
>
> 'IPF22252.1' 'IPF11815.2' 'Contig4-2494_0015'
>
>
> Column 4
>
> 'CA1232'
>
> Thanks, Corinna

Try this example

a = {1 2 [] 4 [] 5}

a =

    [1] [2] [] [4] [] [5]


a(cellfun(@isempty,a)) = []

a =

    [1] [2] [4] [5]

HTH

Anh Huy Phan
RIKEN - BSI

Subject: cells delete empty entries

From: Loren Shure

Date: 18 Jan, 2008 14:45:20

Message: 3 of 4

In article <fmqcvl$5d7$1@fred.mathworks.com>, csc@igb.fhg.de says...
> Hallo,
>
> I have the following problem with a cell construct:
>
>
> hilfe =
>
> Columns 1 through 4
>
> [] [] 'IPF22252.1' 'IPF11815.2'
>
> Column 5 through 8
>
> 'Contig4-2494_0015' [] 'CA1232' []
>
> Column 8
>
> []
>
> Now I want to delete the empty cells. I tried it with the
> command isempty in cooperation with an if-construct. But it
> does not work.
> My aim is such cell construct:
>
> result =
>
> Columns 1 through 3
>
> 'IPF22252.1' 'IPF11815.2' 'Contig4-2494_0015'
>
>
> Column 4
>
> 'CA1232'
>
> Thanks, Corinna
>


c = {3 [] 2 [] 4:5 'q' []}
result = c(~cellfun('isempty',c))

--
Loren
http://blogs.mathworks.com/loren/

Subject: cells delete empty entries

From: Corinna Schmitt

Date: 18 Jan, 2008 15:09:03

Message: 4 of 4

Hallo,

> a(cellfun(@isempty,a)) = []

Thanks it works.

Have a nice weekend, Corinna

Tags for this Thread

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.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com