MATLAB: Getting data from plot

interp1plot

I plot an x , y graph can i ask the programme to tell me the value of y for the value of x i want ? how i can write these at the command window ?

Best Answer

I agree with Jan - it's ambiguous. You already have x, and y since you plotted it, so there's no need to extract anything from the axes (graph) at all. So in that case, I'd just use the x and y which are already available, and if the x is in the x array that you plotted, you can do this:
index = find(x == desiredXValue); % May be multiple indexes, possibly
yDesired = y(index);
Now, if the desired x is not in your x array, then you can use interp1() to get the interpolated/estimated y value for that x.
yDesired = interp1(x,y, desiredXValue);