how to find y axis value's opposite x axis value

2 visualizaciones (últimos 30 días)
skyhunt
skyhunt el 29 de Abr. de 2015
Comentada: KL el 29 de Abr. de 2015
for ex:x=1,2,3,4,5,6;y=2,7,8,9,4,1 i want pick up the y axis (9) opposite x axis value

Respuesta aceptada

KL
KL el 29 de Abr. de 2015
If both vectors are of same size, find the index of your variable from y and use it to pick the value at that position in x. A simple example is
x = [1 2 3 4];
y = [5 6 7 8];
ind = find(y==7);
x(ind);
  2 comentarios
Stephen23
Stephen23 el 29 de Abr. de 2015
Editada: Stephen23 el 29 de Abr. de 2015
Using logical indexing (as per Ilham Hardy's answer) is simpler and faster than using find.
KL
KL el 29 de Abr. de 2015
agreed.

Iniciar sesión para comentar.

Más respuestas (1)

Ilham Hardy
Ilham Hardy el 29 de Abr. de 2015
>> x=[1,2,3,4,5,6];
>> y=[2,7,8,9,4,1];
>> opp_x = x(y==9)
opp_x =
4

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by