How to return i,j locations for contor location

I use the contour command to return the position (lat and lon) of a specified contour depth i.e. 100m isobath.
[c1,h1] = contour(lon_rho,lat_rho,h,[100 100])
where lon_rho and lat_rho are matrices of lon and lat covering my region of interest and h is the bathymetry. These three matrices are all 542x770.
I can pull the lon and lat for the isobath of interest:
Mylon_100=c1(1,:)
Mylat_100=c1(2,:)
But what I want now it the i and j locations within my original matrices (542x770 grid) for each of the points along my contour line - preferably to a fraction of a grid cell.
i.e. maby a pont on the isobath has lat = 61.9 and lon= 175.3 and falls at grid point i=310.3 and j=645.8
Can anyone think of a smart way to get this information for each point along my isobath?
Thanks!

Answers (1)

hi ,
you can find the x/y coordinates of specified value in matrix : let s take a simple example:
G=rand(542,770);
G(400,333)=45; % example
[x,y]=find(G==45)
Does this helps a bit ?

Categories

Tags

Asked:

on 3 Mar 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!