help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constructing arrays


From: Jaroslav Hajek
Subject: Re: Constructing arrays
Date: Wed, 28 Jul 2010 11:11:11 +0200

On Tue, Jul 27, 2010 at 5:36 PM, John W. Eaton <address@hidden> wrote:
> On 26-Jul-2010, Andy Buckle wrote:
>
> | >a=floor(rand(1,16)*3)
> | a =
> |
> |    1   0   1   0   1   0   1   2   0   2   1   0   0   0   0   2
> |
> | >a(find(a==0))=[]
> | a =
> |
> |    1   1   1   1   2   2   1   2
>
> The call to find is not necessary here.  You can use
>
>  a(a == 0) = []
>
> to do the same thing.
>

FWIW, this is also slightly more efficient.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]