Find where the vertical line intersects the y values
Ältere Kommentare anzeigen
I have attached the plot I generated for a data set. I would like to find the points where the vertical lines intersect the y-values. Further, is there a way to just plot a point (or a marker) instead of the vertical lines? I am just plotting a time stamp using the vertical line.

Antworten (1)
Star Strider
am 25 Apr. 2016
0 Stimmen
You obviously have the x values, so I would use the interp1 function to find the y values in your data.
4 Kommentare
Dushyant Dhundara
am 25 Apr. 2016
Star Strider
am 25 Apr. 2016
The vertical lines from your known desired ‘x’ do not have to be dependent on existing ‘y’ values. That is the idea behind interpolation.
I do not have your data or vector of ‘x’ values representing the vertical lines, so I cannot write code precisely for it. If you are getting NaN results, you may need to ask interp1 to extrapolate. For example:
xi = ...; % Vector Of ‘x’ Values To Interpolate
yi = interp1(x, y, xi, 'linear', 'extrap'); % Produces Vector Of ‘yi’ Values Matching ‘xi’
You must specify a method (here 'linear') and that you want interp1 to extrapolate (so add the 'extrap' argument).
Dushyant Dhundara
am 25 Apr. 2016
Bearbeitet: Dushyant Dhundara
am 25 Apr. 2016
Star Strider
am 25 Apr. 2016
My pleasure.
If my Answer solved your problem, please Accept it!
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!