help-octave
[Top][All Lists]
Advanced

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

RE: Abs highest(extreme) value in a matrix with +ve & -ve elements


From: Mechanical Mon
Subject: RE: Abs highest(extreme) value in a matrix with +ve & -ve elements
Date: Tue, 24 Jan 2012 02:05:30 -0600

> -----Original Message-----

> From: Ben Abbott [mailto:address@hidden]

> Sent: Monday, January 23, 2012 8:55 AM

> To: adla.raghu

> Cc: address@hidden

> Subject: Re: Abs highest(extreme) value in a matrix with +ve & -ve

> elements

>

> On Jan 23, 2012, at 8:31 AM, adla.raghu wrote:

>

> > Hi sorry for any confusion.

> >

> > By saying "extreme value" I meant if we consider the range of the

> > values on a number scale

> >

> > Eg: A(:,1) = [1,3,-5,9,-7,10]  are arranged as -7,-5,1,3,9,10 where

> > 10 is the extreme value

> >

> >     A(:,2) = [1,3,-5,9,7,-10] are arranged as -10, -5, 3, 7,9 where

> > -10 is the extreme value

> >

> > So if I say min(A) it returns -7,-10   but the extreme values are 10,

> -10

> > And if I say max(A) it returns 10, 9 but the extreme values are again

> > 10,

> > -10

> >

> > I hope this makes sense

> >

> > thanks

>

> I'm not sure, but does this work ?

>

>     [Amax, nmax] = max (abs (A));

>     Extremes = [-Amax; Amax]

>

> Ben

>

 



I think this may be what you're looking for:

clear all;
A=randn(100,2)
B=max(A)+min(A);
for ii=1:length(B)
if (sign(B(:,ii))>=0)
out(:,ii)=max(A(:,ii));
else
out(:,ii)=min(A(:,ii));
endif
endfor
out
for i=1:length(out)
C(i,:)=[out(i); find(A==(out(:,i)))];
endfor
C

#end

There are probably more elegant ways of achieving this, but it works.

Mon

reply via email to

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