Hello all I have a plotted a graph with x=1 2 3 4 5 and y = 2 4 6 8 10. Now I want to mark y= 6.5 on the plot. How to do it. I have asked this question in a simple way but the actual data I have is so big. Hoping for suggestions Thanking you

 Respuesta aceptada

esat gulhan
esat gulhan el 18 de Sept. de 2020

0 votos

Maybe like this
clc;clear;
x=[1 2 3 4 5]; %x data
y =[2 4 6 8 10];%y data
yy=6.5 % y value you intend to reach
xx = interp1(y,x,yy,'spline') %interpolation type, i choose spline, but you can choose pchip,lineer etc...
plot(xx,yy,'o'); %plot value
hold on
plot(x,y,'r'); grid on; %plot x y datas

3 comentarios

Vinay Srinivasan
Vinay Srinivasan el 18 de Sept. de 2020
First of all thank you so much for replying In the line XY=interp1(y,x,XY,'spline') What is the y and X value I should give ?
esat gulhan
esat gulhan el 18 de Sept. de 2020
it depends what you want. yy is changeble. If you change yy=6.5 ,yy=6 it changes x =3, if you give yy =3 x will be 1.5.
If you write yy=[3 5 7] you see 1.5 2.5 3.5 three marks on graph.
Vinay Srinivasan
Vinay Srinivasan el 18 de Sept. de 2020
Ok thank you so much, it worked

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Sept. de 2020

Comentada:

el 18 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by