How to find X Value given Y value and show the point on a plot

12 vues (au cours des 30 derniers jours)
Matlab_Student
Matlab_Student le 8 Oct 2017
Commenté : Onu Student le 5 Nov 2020
I have an semilog plot below.
%
x = 0:1:25;
y = exp(-0.03*x);
figure;
semilogy(x,y);
%
I want to let the program calculate the x value when y=0.5 and indicate this point (x,0.5) on the plot with dashed lines connecting to the two axes. How do I achieve this?

Réponse acceptée

KSSV
KSSV le 9 Oct 2017
x = 0:1:25;
y = exp(-0.03*x);
figure;
semilogy(x,y);
%
yi = 0.5 ;
xi = interp1(y,x,yi) ;
hold on
semilogy(xi,yi,'*r')
  4 commentaires
Coryn Melissa LLamoza Carabali
yes! looking for both questions above. Anybody that can help with this ;(
Onu Student
Onu Student le 5 Nov 2020
you can add annotations to plots text(x,y,txt)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by