How to find (0,0) in a meshgrid?

2 ビュー (過去 30 日間)
Julian Blackthorne
Julian Blackthorne 2021 年 9 月 1 日
編集済み: Julian Blackthorne 2021 年 9 月 1 日
Is there a way to find the origin (0,0), without using a for loop for the meshgrid generated below?
ii = -15:15
jj = -10:10
[a,b] = meshgrid(ii,jj);
figure(1)
scatter(a(:), b(:), '.', 'k');
  1 件のコメント
KSSV
KSSV 2021 年 9 月 1 日
There is no (0, 0). What you have is a single point. How you expect to find?

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

採用された回答

KSSV
KSSV 2021 年 9 月 1 日
x = -10:1:10 ;
y = -5:1:5 ;
[X,Y] = meshgrid(x,y) ;
idx = knnsearch([X(:) Y(:)],[0 0]) ;
plot(X,Y,'.r')
hold on
plot(X(idx),Y(idx),'ob')
  1 件のコメント
Julian Blackthorne
Julian Blackthorne 2021 年 9 月 1 日
Thank You, this was exactly what I was looking for!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by