[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get a matrix values' indices?
From: |
Quentin Spencer |
Subject: |
Re: How to get a matrix values' indices? |
Date: |
Tue, 28 Sep 2004 13:26:22 -0500 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
You're looking for the "find" function, as in this example:
octave:1> x=[1,2,3;1,2,2;1,1,3];
octave:2> [ii,jj]=find(x==1);
octave:3> [ii,jj]
ans =
1 1
2 1
3 1
3 2
Mikolaj Karolczak wrote:
Hello,
Suppose we have a matrix of integer values. Is there any function to get quickly
matrices of each value's indices?
e.g.
I have:
[1 2 3
1 2 2
1 1 3]
I want:
-> 1: [1 1; 2 1; 3 1; 3 2]
-> 2: [1 2; 2 2; 2 3]
-> 3: [1 3; 3 3]
Surely I can get it by checking the value for every index but for big matrices
if works slowly.
Actually I need to calculate the 'specific gravity' of each value in the matrix
- the mean values of each value's indices. Maybe there is a function to do it
yet simplier?
Rgds,
Mikolaj
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------