No BSD License  

Highlights from
Find coordinates

2.0

2.0 | 10 ratings Rate this file 7 Downloads (last 30 days) File Size: 1.28 KB File ID: #8136

Find coordinates

by Chris Riederer

 

27 Jul 2005 (Updated 27 Jul 2005)

Input a value and a matrix, and this function will output the row(s) and column(s) of the value.

| Watch this File

File Information
Description

getcoord(value,matrix)
This function finds the value inside of a matrix containing it. Imput first the value, then the matrix, and the output will be in the form of a vector [r c] with r being the row of the value and c being the column. If the value is present multiple times, the output will be have more rows of [r c]. You can also type in the function in the form getcoord(COORDVAL, MATRIX, RANGEROW, RANGECOL)
where rangerow and rangecol are vectors of integers less than or equal to the dimension of the matrix. This simply finds the value or values in the specified area.

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (14)
27 Jul 2005 Jos x

The very very basic command
[r,c] = find(M=V)
will do the same thing, and much quicker !

27 Jul 2005 majj maha

I agree with Jos x

28 Jul 2005 Robert Young

MatLab command find already does this.

29 Jul 2005 ciccio balu

it may be of some interest if you extend to N-dimensional matrices

indded matlab [i,j] = find(..) works only with 2d matrice

matlab does not [i,j,k]=find(...)

29 Jul 2005 K Morton

Finally! I really needed a less general find.

29 Jul 2005 Jos x

Generalized find:
M is your N-dimensional matrix
V is your value
clear ind ; [ind{1:ndims(M)}] = ind2sub(size(M),find(M=V))

29 Jul 2005 Jos x

Sorry, M==V instead of M=V
clear ind ; [ind{1:ndims(M)}] = ind2sub(size(M),find(M==V))

01 Aug 2005 Chris Riederer

Thanks guys, I didn't realize you could use the find( command that way. This will help speed up some of my programs.

09 Aug 2005 Them Them  
08 Sep 2005 Demyan .

Duplicates built-in FIND.

21 Sep 2006 noam zick

the city hall of philadelphia

22 May 2008 Arnaud Laurent

use [r c] = find(matrix,value) instead.

03 Jun 2010 Vanessa  
03 Jun 2010 Vanessa

Thank you for this useful piece of code. I needed something that would search through a matrix and return the location of the number -9999. The find function in Matlab could not do this. According to the help file the find function will "Find indices and values of nonzero elements". Thanks again!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrices Chris Riederer 22 Oct 2008 07:54:24
coordinates Chris Riederer 22 Oct 2008 07:54:24
find Chris Riederer 22 Oct 2008 07:54:24
get Chris Riederer 22 Oct 2008 07:54:24
matrix Chris Riederer 22 Oct 2008 07:54:24
value Chris Riederer 22 Oct 2008 07:54:24
spot Chris Riederer 22 Oct 2008 07:54:24

Contact us at files@mathworks.com