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 12:21:55 -0500

On 23 January 2012 11:29, adla.raghu <address@hidden> wrote:
> Cracking, it works, I replaced the ~ with 'X' .

It looks like you're using Octave 3.2.3 or earlier. You should try to update.

> Didnot quite understand line 2 though. wish u could explain

I guess U'RE referring to this line:

       m = A(sub2ind (size(A), idx, 1:columns (A)));

If that's so, it's an indexing hack I wish I could avoid. Once U have
the row indices per column, U can use sub2ind to transform those
column + rows (i.e. 1:columns(A) subscripts into linear indices, as if
the matrix were flattened and written columnwise like this:

    A = [10  40  70
         20  50  80
         30  60  90]

Thus for example A(2) is 20 and A(8) is 80.

HTH,
- Jordi G. H.


reply via email to

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