How to mark a point in a MATLAB plot?

 I have this plot 

I need to make a straight vertical line at a point on x axis that the user enters and show the coordinates of the intersection of that vertical line with my plot.

How can this be done in MATLAB?

for example: the user enters 1020 then a straight vertical line will be drawn at 1020 that meets the plot at some point and the coordinates of that point will be shown somehow.  

NOTE:-


Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.        

Answers: 

One way to do this is to use the GINPUT function to graphically select a point using the mouse. Assuming the data you plotted is stored in a variable data, the following code should do the sort of thing you want. 

 

set(gca,'XLimMode','manual','YLimMode','manual');  % Fix axes limits
hold on;
[x,y] = ginput(1);  % Select a point with the mouse
x = round(x);       % Round x to nearest integer value 
SEE COMPLETE ANSWER CLICK THE LINK        
https://matlabhelpers.com/questions/how-to-mark-a-point-in-a-matlab-plot-.php

Comments

Popular posts from this blog

How to Perform LU Decomposition with Partial Pivoting in Matlab

Why Red, Green, Blue channels of image separetely are grayscaled (Matlab)?

How to MATLAB: Extract multiple parts of a matrix without using loops