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: Jordi Gutiérrez Hermoso
Subject: Re: Abs highest(extreme) value in a matrix with +ve & -ve elements
Date: Mon, 23 Jan 2012 08:24:25 -0500

On 23 January 2012 08:16, Ben Abbott <address@hidden> wrote:
> On Jan 23, 2012, at 8:03 AM, adla.raghu wrote:
>
>> Thanks for your reply, but  I am trying to retrieve only the extreme value in
>> each column retaining its -ve/+ve symbol.[and its index as well]
>>
>> So when I do min(); it's giving me the minimum value in the column ignoring
>> the +ve values.
>>
>> Eg: if I have a column in A as [1,3,-5,7,-9,10]
>>         min(A(x)) returns -9 but the extreme value [abs max] is 10
>>
>>     if I have another column in the matrix A as [1,3,-5,7,-9]
>>         max(A(x)) returns 7 while the extreme value is -9.
>>
>>    So while looping through the entire matrix A, I either get the max
>> values or min but not the extreme values, the ones I am looking for.
>
> Can you give us a better description of what "+ve" and "-ve" are ?

Positive and negative. I think it's a Commonwealth English
abbreviation.

> Qualifying them as "extreme values" doesn't see to be correct. min()
> and max() arguably do return the extreme min and max values.
>
> For your two examples above what do you define as the extreme values
> ?

Adla wants to get the maximum absolute values, and then go back into
the matrix to retrieve the corresponding sign. This seems to work for
me:

    [~, idx] = max (abs (A));
    m = A(sub2ind (size(A), idx, 1:columns (A)));

HTH,
- Jordi G. H.


reply via email to

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