|
|
Removal of empty entries in an array (fast)
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
|
|
|
|
Reply
|
Mohit
|
12/29/2010 10:21:04 AM |
|
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
|
|
|
|
Reply
|
Walter
|
12/29/2010 10:27:30 AM
|
|
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
|
|
|
|
Reply
|
Mohit
|
12/29/2010 10:36:06 AM
|
|
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
|
|
|
|
Reply
|
Bruno
|
12/29/2010 10:41:06 AM
|
|
|
3 Replies
459 Views
(page loaded in 0.037 seconds)
|
|
|
|
|
|
|
|
|