How to find a value in a matrix
1 view (last 30 days)
I have a matrix of latitude and another matrix of longtitude for the location of an area pixel to pixel. I have a location value (longtitue and latitude) that I want to find the position of the pixels which this value will be located in. How can I find this?
Look at below to the exemplary matrix of Latitude.
There is another matrix like this for longtitudeThe point that I am looking for is Latitude=35.6886 and Longtitude= 53.6113
DGM on 27 Nov 2021
Consider the simple example:
% two orthogonal grids
[x y] = meshgrid(linspace(0,1,10))
% the point you're trying to locate
targetpt = [0.3333 0.5555]; % [x y]
tol = 0.001; % tolerance
% the row and column where the point is found
[tprow tpcol] = find(abs(x-targetpt(1))<tol & abs(y-targetpt(2))<tol)
Don't expect simple equality tests to work with floating point numbers like this. You'll have to test matches to within some defined tolerance.