How to generate a 2D meshgrid based on the coordinates (longitude and latitude) of points

15 ビュー (過去 30 日間)
I have several points' coordinates, I want to merge a meshgrid of the points looks like the following figure.
For example, I have five points with coordinates info, the ideal generated meshgrid should be like this (the purple square which is overshadowed).
Thank you very much!

採用された回答

Voss
Voss 2022 年 6 月 19 日
xy = [1 3; 2 9; 6 6; 8 8; 9 1];
% [xx,yy] = meshgrid(sort(xy(:,1)),sort(xy(:,2))) % note: maybe you want to sort x and y first
[xx,yy] = meshgrid(xy(:,1),xy(:,2))
xx = 5×5
1 2 6 8 9 1 2 6 8 9 1 2 6 8 9 1 2 6 8 9 1 2 6 8 9
yy = 5×5
3 3 3 3 3 9 9 9 9 9 6 6 6 6 6 8 8 8 8 8 1 1 1 1 1
plot(xy(:,1),xy(:,2),'ok','MarkerFaceColor','k')
hold on
xline(xx(1,:))
yline(yy(:,1))
xlim([0 10]);
ylim([0 10]);
set(gca(),'Visible','off')
  5 件のコメント
Voss
Voss 2022 年 6 月 19 日
You're welcome!
Wang Zhen
Wang Zhen 2022 年 6 月 20 日
Hi, here is another problem I encountered which is associated with this, please take a look if you are free.
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by