help-octave
[Top][All Lists]
Advanced

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

Re: a(a>1) returns 1-D list, also for matrix. Can it be done per column?


From: Juan Pablo Carbajal
Subject: Re: a(a>1) returns 1-D list, also for matrix. Can it be done per column?
Date: Thu, 8 Mar 2012 23:24:45 +0100

On Thu, Mar 8, 2012 at 10:41 PM,  <address@hidden> wrote:
> Dear all,
>
> v1=[1;0;4;56;25;10;0];
> v2=[10;20;156;125;50;20;5];
> m=[v1,v2];
> m(m>30)
>
> gives for m:
>
> ans =
>
>   5.6000e+01
>   1.5600e+02
>   1.2500e+02
>   5.0000e+01
>
> Can I make/use the mask "m>30" "per column", that is: for each of the (two) 
> columns?
> So:
>
>   5.6000e+01       1.5600e+02
>                    1.2500e+02
>                    5.0000e+01
>
>
> The reason I ask this, it because I have several vectors (=columns) of data 
> and
> for each I'd like to estimate the FWHM value, by masking for each vector v
> "v>max(v)/2". This gives a list, so I don't know which data belong to which
> vector.
>
> If you have only 1 column, you can do v.*(v>max(v)./2), but for more than 1 
> column, it doesn't work.
>  Or do I misunderstand the power of index-masks?
>
> thanks for any suggestions!
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

You have to realize that the output of the "mask" per column cannot be
stored in a matrix, so you need a cell. Otherwise you can use a matrix
with NA values and fill the right places with you mask.

- Using a NA matrix
M = NA (rows,cols);
tf = m > 30;
M(tf) = m(tf);

M has your filtered data.

If you do not need the values but the position on the matrix m just
use the function find()
[r c] = find(m>30)

the pair [r(i) c(i)] gives you the position in m if the i-th element
fulfilling your condition.

Hope this helps


-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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