help-octave
[Top][All Lists]
Advanced

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

Re: Vectorize an extraction


From: Jaroslav Hajek
Subject: Re: Vectorize an extraction
Date: Thu, 2 Dec 2010 21:44:42 +0100

On Thu, Dec 2, 2010 at 7:16 PM, John W. Eaton <address@hidden> wrote:
> On  2-Dec-2010, keithspg wrote:
>
> |
> | I did not know how best to title this, but I am working on analysis of a 
> data
> | set. In that set, there are values I do not want to consider nor plot as
> | they are zero. Currently, I am using this loop to extract the values I want
> | (all voltages >0.5)
> |                 j=1;
> |               for i = 1:(size(data,1)-1); # extracting only loaded values 
> loop
> |               if(data(i,2) > 0.5);
> |               loaded(j,1)=data(i,1);
> |               loaded(j,2)=data(i,2);
> |               j=j+1;
> |               endif
> |               endfor
> |
> | I was hoping to make this faster in execution by vectorizing this and am
> | looking for advice on how best to do it.
>
> Maybe something like this?
>
>  idx = find (data(1:(end-1),2) > 0.5);
>  loaded1 = data(idx,1:2);
>

Note that find() is not necessary here and the code will even be (very
slightly) more efficient without it.



reply via email to

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