COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Removal of empty entries in an array (fast)

• Follow

```I have a very large array 360,000 and I want to remove the odd 20-30 empty cells in the array. How can this be done without increasing computational speed by much?
```
 0

```On 29/12/10 4:21 AM, Mohit Thukral wrote:
> I have a very large array 360,000 and I want to remove the odd 20-30
> empty cells in the array. How can this be done without increasing
> computational speed by much?

A = A(cellfun(@(C) ~isempty(C), A));

Though possibly it might be faster to use

A(cellfun(@isempty,A)) = [];

```
 0

```Walter Roberson <roberson@hushmail.com> wrote in message <n2ESo.26567\$Qi5.6376@newsfe01.iad>...
> On 29/12/10 4:21 AM, Mohit Thukral wrote:
> > I have a very large array 360,000 and I want to remove the odd 20-30
> > empty cells in the array. How can this be done without increasing
> > computational speed by much?
>
> A = A(cellfun(@(C) ~isempty(C), A));
>
> Though possibly it might be faster to use
>
> A(cellfun(@isempty,A)) = [];

That is very fast. Thank you for the assistance.
```
 0

```Walter Roberson <roberson@hushmail.com> wrote in message <n2ESo.26567\$Qi5.6376@newsfe01.iad>...
> On 29/12/10 4:21 AM, Mohit Thukral wrote:
> > I have a very large array 360,000 and I want to remove the odd 20-30
> > empty cells in the array. How can this be done without increasing
> > computational speed by much?
>
> A = A(cellfun(@(C) ~isempty(C), A));
>
> Though possibly it might be faster to use
>
> A(cellfun(@isempty,A)) = [];

None of that is fastest. Thes fastest is this:

C(cellfun('isempty',C)) = [];

Bruno
```
 0

3 Replies
459 Views

Similiar Articles:

7/27/2012 4:46:53 PM