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: indium
Subject: Re: a(a>1) returns 1-D list, also for matrix. Can it be done per column?
Date: Fri, 9 Mar 2012 10:17:35 +0000
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, Mar 08, 2012 at 11:24:45PM +0100, Juan Pablo Carbajal wrote:
> 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/

Dear Juan,

thank you! indeed, the NA matrix does the job: if the columns of m contain
each one peak (gaussian), the M matrix contains the columns with the upper
part of the peaks. The FWHM estimate I want to do is basically max(M)-min(M)
which is correctly selected, because all other elements are now 'NA'.

thanks!


reply via email to

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