loop

Carlo Rossi serosole at yahoo.it
Thu Jun 4 13:58:42 CDT 2009


I wrote this:
[cc, pp] = max (counting, [], 2);

pp will contains the indexes of columns of matrix (counting is a matrix) with the maximun values;

counting = [  2 2 1;
              0 0 1;
              1 0 4;
];

with [cc, pp] = max (counting, [], 2);
I'll have:
 cc = [2; 1; 4]
 pp = [1; 3; 3 ]
I need to change pp in this way:

pp = [ 0  2  2 ];

i.e. pp-1 and traspose it (as before was a column vector)

is it possible achieve it in this line:

 [cc, pp] = max (counting, [], 2);

without do:
 pp = (pp-1)'

thanks,


--- Gio 4/6/09, Jaroslav Hajek <highegg at gmail.com> ha scritto:

> Da: Jaroslav Hajek <highegg at gmail.com>
> Oggetto: Re: loop
> A: "Carlo Rossi" <serosole at yahoo.it>
> Cc: help-octave at octave.org
> Data: Giovedì 4 giugno 2009, 20:41
> On Thu, Jun 4, 2009 at 3:55 PM, Carlo
> Rossi <serosole at yahoo.it>
> wrote:
> >
> >> There was a typo, sorry:
> >> [cc, pp] = max (counting, [], 2);
> >
> > Hi, Ifinally understand this. Anyway I need the
> indexes (I suppose pp) in this way:
> >
> >
> > (indexes')-1
> >
> > is there a way to do all in:
> >  [cc, pp] = max (counting, [], 2);
> >
> > Actaully I need only the indexes (pp) not the
> values..
> > thansk,
> >
> >
> 
> I really don't understand what you want. Try explaining
> your problem
> in a more detailed way.
> 
> cheers
> 
> -- 
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
> 


      




More information about the Help-octave mailing list