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

4 visualizaciones (últimos 30 días)
Julian Blackthorne
Julian Blackthorne el 1 de Sept. de 2021
Editada: Julian Blackthorne el 1 de Sept. de 2021
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 comentario
KSSV
KSSV el 1 de Sept. de 2021
There is no (0, 0). What you have is a single point. How you expect to find?

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 1 de Sept. de 2021
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 comentario
Julian Blackthorne
Julian Blackthorne el 1 de Sept. de 2021
Thank You, this was exactly what I was looking for!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by