How to find elements in grid?

6 次查看(过去 30 天)
Hello, I defined a grid onto a map that I plotted with MAP library. This grid contains some elements and I know the density of each grid (which one contains what amount of elements). But now I need to find which element belongs to which grid.
Here is my code,
LAT1=39;LAT2=42;LON1=29.0;LON2=41.0;
sf = 1;
m_proj('albers equal-area','lat',[LAT1 LAT2],'long',[LON1 LON2],'rect','on');m_gshhs_h('color',[.5 .5 .5]);hold on;
m_grid('linewi',1,'linest','none','tickdir','in','fontsize',10);
all = load('all_velocities.txt');
lon1=all(:,1);lat1=all(:,2);ve1=all(:,3);vn1=all(:,4);
%density of the plots
dLO = .5*2; dLA = .3636*2;
lon = [LON1:dLO:LON2];
lat = [LAT1:dLA:LAT2];
for i = 1:length(lat)
for j = 1:length(lon)
DENSITY(i,j) = length(find(abs(lat1-lat(i))<dLA/2 & abs(lon1-lon(j))<dLO/2));
end
end
m_pcolor(lon-dLO/2,lat-dLA/2,DENSITY);colormap(jet);
m_quiver(lon1,lat1,sf.*ve1,sf.*vn1,1,'w','filled','AutoScale','off','linewidth',1.5);
hold off;
You can find "all_velocities.txt" attached and also attached figure shows my map, my grid onto it, and color indicates the grid density.
  1 个评论
Image Analyst
Image Analyst 2020-1-23
编辑:Image Analyst 2020-1-23
Unfortunately, you forgot to attach 'all_velocities.txt'. I doubt anyone will answer until then. Attaching a screenshot would also help you get an answer.

请先登录,再进行评论。

回答(1 个)

Sevil Cansu Yildirim
I am so sorry, here is "all_velocities.txt" attached. Also figure attached shows my map, grid and data. Color indicates the data density in every grid, now I want to know which data belongs to which grid.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by