How to find elements in grid?

2 ビュー (過去 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 Center および File ExchangeCreating, 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