How to find elements in grid?

조회 수: 1 (최근 30일)
Sevil Cansu Yildirim
Sevil Cansu Yildirim 2020년 1월 23일
편집: Sevil Cansu Yildirim 2020년 1월 23일
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
Sevil Cansu Yildirim 2020년 1월 23일
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에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by