Main Content

findm

Latitudes and longitudes of nonzero data grid elements

Syntax

[lat,lon] = findm(Z,R)
[lat,lon] = findm(latz,lonz,Z)
[lat,lon,val] = findm(...)
mat = findm(...)

Description

[lat,lon] = findm(Z,R) computes the latitudes and longitudes of the nonzero elements of a regular data grid, Z. Specify R as a GeographicCellsReference or GeographicPostingsReference object. The RasterSize property of R must be consistent with size(Z).

[lat,lon] = findm(latz,lonz,Z) returns the latitudes and longitudes of the nonzero elements of a geolocated data grid Z, which is an M-by-N logical or numeric array. Typically latz and lonz are M-by-N latitude-longitude arrays, but latz may be a latitude vector of length M and lonz may be a longitude vector of length N.

[lat,lon,val] = findm(...) returns the values of the nonzero elements of Z, in addition to their locations.

mat = findm(...) returns a single output, where mat = [lat lon].

This function works in two modes: with a regular data grid and with a geolocated data grid.

Examples

collapse all

Load elevation data and a geographic cells reference object for the world.

load topo60c

Find the coordinates with elevations that are greater than 5500 meters. The elements of idx are 1 when the corresponding element of topo60c is greater than 5500, and 0 otherwise.

idx = topo60c > 5500;
[lat,lon] = findm(idx,topo60cR)
lat = 4×1

   34.5000
   34.5000
   30.5000
   28.5000

lon = 4×1

   79.5000
   80.5000
   84.5000
   86.5000

Find the elevations at these locations by indexing into the elevation data.

h = topo60c(idx)
h = 4×1

        5559
        5515
        5523
        5731

Version History

Introduced before R2006a

expand all