help-octave
[Top][All Lists]
Advanced

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

help using dimensions on min()


From: Chris Daamen
Subject: help using dimensions on min()
Date: Fri, 28 Jun 2013 14:00:52 +0200

I am sure I am overlooking something very simple, but I cannot see it. My 
Octave experience is indeed limited, working with it for two months now. 

To get a row vector of the minimal values of each column of a matrix, and a row 
vector of the indices of the first minimum in each column, I do
min(matrix, [], 1)

same for getting two column vectors with minima and indices, giving values per 
row:

min(matrix, [], 2)

Though sometimes this does not work. I reduced the nested for loops that 
generate my matrix to this:

testMatrix = [2, 3, 4, 5, 6;
                                3, 4, 5, 6, 7;
                                4, 5, 6, 7, 8;
                                5, 6, 7, 8, 9;
                                6, 7, 8, 9, 10]
                                
dimensiontestMatrix = ndims(testMatrix)

[min, minSigma] = min(testMatrix,[],1)
[min, minC] = min(testMatrix,[],2)

result is

octave-3.4.0:24> run debug2.m
testMatrix =

    2    3    4    5    6
    3    4    5    6    7
    4    5    6    7    8
    5    6    7    8    9
    6    7    8    9   10

dimensiontestMatrix =  2
A(I,J,...): index to dimension 1 out of bounds; value 10 out of bound 5
error: called from `debug2.m' in file /Users/some/info/here/debug2.m near line 
9, column 18
error: called from:
error:   
/Applications/Octave.app/Contents/Resources/share/octave/3.4.0/m/miscellaneous/run.m
 at line 55, column 7

The message 'index to dimension 1 out of bounds' confuses me, even more what 
comes after... 10 is not an index into the matrix, it is a value in the matrix! 
I am probably overlooking something very simple... be gentle ok :)

As you can probably see from the above error message, I am on OSX and use the 
provided Octave binary which is at 3.4.0







reply via email to

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