help-octave
[Top][All Lists]
Advanced

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

Re: about the minimum of elements of a matrix


From: CdeMills
Subject: Re: about the minimum of elements of a matrix
Date: Tue, 21 Dec 2010 02:00:26 -0800 (PST)


Martin Helm wrote:
> 
> 
>> 
> This will show the first element which has the minimum value. If all index 
> pairs are of interest where the matrix has its minimum value:
> 
> val = min(A(:));
>  [i,j] =ind2sub(size(A),find(A==val));
> 
> 

The problem with 'find' is that it may return a vector instead of a scalar.
What about:
[idxi, idxj] = min(A, [], 2); %# iterates on lines -- returns vectors
[Amin, idxi] = min(idxi);    %# mimimum value and row index 
idxj = idxj(idxi);                %# column index
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/about-the-minimum-of-elements-of-a-matrix-tp3098259p3139241.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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