Extracting elements of a matrix based on latitude & longitude limits
Show older comments
I'm using the following code to extract elements of matrix z (180*360) which are within the boundary enclosed by xq & yq (limits of lat & lon). It returns only a 1*4 array which is not the desired output. Could you please help in improving this. (xvertices & yvertices are based on the latitude (180*1) & longitude (360*1) matrices) -Thank you-
A=ncread('GRD-3-2002094-2002120-GRAC_JPLEM_BA01_0600_LND_v04.nc','lwe_thickness');
A=A';
z=A(:,:);
xq=[110,160,160,110];
yq=[-10,-10,-40,-40];
xvertices=[0.5,359.5,359.5,0.5];
yvertices=[-89.5,-89.5,89.5,89.5];
data=inpolygon(xq,yq,xvertices,yvertices);
data_z=z(data)
Accepted Answer
More Answers (0)
Categories
Find more on Geoscience in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!