How to find elements in grid?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Image Analyst
le 23 Jan 2020
Modifié(e) : Image Analyst
le 23 Jan 2020
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.
Réponses (1)
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!