[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: How to get a matrix values' indices?

**From**: |
Keith Goodman |

**Subject**: |
Re: How to get a matrix values' indices? |

**Date**: |
Tue, 28 Sep 2004 11:22:52 -0700 |

>* x*
x =
1 2 3
1 2 2
1 1 3
>* [i,j] = find(x==1);*
>* [i j]*
ans =
1 1
2 1
3 1
3 2
>* mean([i j])*
ans =
2.2500 1.2500
>
On Tue, 28 Sep 2004 20:12:53 +0200, Mikolaj Karolczak
<address@hidden> 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
-------------------------------------------------------------