Thread Subject: cell array deleting columns without using cellfun

Subject: cell array deleting columns without using cellfun

From: Corinna Schmitt

Date: 26 Nov, 2007 13:59:36

Message: 1 of 5

Hallo,
I am working with an old version of Matlab (V6). There the
function cellfun is not yet implemented. So the consequence
is the following problem:

I have a cell array which look like this

value_tag_coding_for_columns =

     [] []
     [] []
    'C' [1x23 char]
    'D' [1x23 char]

How can I delete the rows 1 and 2 without using cellfun?

If I would do it with cellfun then with the following
commands:

toBeDeleted=[cellfun(@isempty,value_tag_coding_for_columns
(1:size(value_tag_coding_for_columns,1)-1,size
(value_tag_coding_for_columns,2)));false];
value_tag_coding_for_columns(toBeDeleted,:)=[]


Thanks, Corinna

Subject: cell array deleting columns without using cellfun

From: Corinna Schmitt

Date: 26 Nov, 2007 14:09:15

Message: 2 of 5

Sorry, I meant deleting rows.

But the solution for deleting columns in cells without
cellfun usage would be nice.

Thanks, Corinna

Subject: cell array deleting columns without using cellfun

From: Bruno Luong

Date: 26 Nov, 2007 14:58:59

Message: 3 of 5

"Corinna Schmitt" <csc@mathworks.com> wrote in message
<fiek2b$rg0$1@fred.mathworks.com>...
> Sorry, I meant deleting rows.
>
> But the solution for deleting columns in cells without
> cellfun usage would be nice.
>
> Thanks, Corinna
>

You don' want using for loop?

Bruno

Subject: cell array deleting columns without using cellfun

From: Corinna Schmitt

Date: 26 Nov, 2007 15:05:26

Message: 4 of 5

Hallo Bruno,
> You don' want using for loop?

Ok, for a first step I accept for-loops. But how is then
the solution?

Thanks, Corinna

Subject: cell array deleting columns without using cellfun

From: Bruno Luong

Date: 26 Nov, 2007 15:46:17

Message: 5 of 5

"Corinna Schmitt" <csc@mathworks.com> wrote in message
<fienbm$g2g$1@fred.mathworks.com>...
> Hallo Bruno,
> > You don' want using for loop?
>
> Ok, for a first step I accept for-loops. But how is then
> the solution?
>
> Thanks, Corinna
>

The only thing one need to pay attention is the loop must
run in reverse, so that there is no delete side effect from
one iteration to the next.

I let you treat the special last-row case as your original
code suggested:

for nrow=size(value_tag_coding_for_columns,1):-1:1
    if isempty(value_tag_coding_for_columns{nrow,end})
        value_tag_coding_for_columns(nrow,:)=[];
    end
end

Bruno

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