Read value from a graph

6 views (last 30 days)
Marcel Been
Marcel Been on 26 Aug 2014
Commented: Marcel Been on 26 Aug 2014
I want to read a value from a graph. I´ve got two matrices (X & Y) and plotted in a graph. I want to know the value of Y when i enter the value of X.
PLEASE help me with a code for this problem.
y =[1;1.09300000000000;1.24200000000000;1.39900000000000;1.56400000000000;
Total=[matrix1 matrix2];

Answers (1)

Ben11 on 26 Aug 2014
Edited: Ben11 on 26 Aug 2014
Not sure to understand how you would like to 'enter' the value of x, but here is a very simple example:
User_x = inputdlg('Enter a value for x'); % Ask the user what value of x he wants
while ~any(ismember(str2double(User_x),x)) % Check if the entered value is indeed in X.
User_x = inputdlg('Enter a value for x');
X_index = find(str2double(User_x) == x,1,'first') % Find the index in y
Y_value = y(X_index); % Find the corresponding value
Message = sprintf('The corrsponding y-value is %0.12f \n',Y_value); % Write a message
msgbox(Message) % Display the message
Hope that helps!
  1 Comment
Marcel Been
Marcel Been on 26 Aug 2014
Thanks for your answer, but it isn't what i need. I want to use this command for my simulink simulation. I attached my programm. I want to search for the 'value' of 'Ethalpy Power_1' in the graph (X, Y) and then the Y-value have to appear. So i can use it in my other graph.
If i've got this command, the chart-block will be removed.
Hopefully you (or somebody else) got the answer for this problem.

Sign in to comment.


Find more on Specifying Target for Graphics Output in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!