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 CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by