Read value from a graph

3 vues (au cours des 30 derniers jours)
Marcel Been
Marcel Been le 26 Août 2014
Commenté : Marcel Been le 26 Août 2014
Hello,
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.
.
CODE:
x=[-879.320000000000;-877.030000000000;-873.430000000000;-869.850000000000;
-866.210000000000;-862.600000000000;-858.900000000000;-857.340000000000;
-855.290000000000;-851.630000000000;-847.980000000000;-844.240000000000;
-840.530000000000;-840.010000000000;-836.820000000000;-833.130000000000;
-829.330000000000;-825.400000000000;-825.400000000000;-821.790000000000;
-818.020000000000;-814.170000000000;-812.670000000000;-810.360000000000;
-806.480000000000;-802.630000000000;-801.150000000000;-798.710000000000;
-794.820000000000;-790.830000000000;-790.620000000000;-786.910000000000;
-782.920000000000;-780.940000000000;-778.930000000000;-774.870000000000;
-771.790000000000;-770.810000000000;-766.750000000000;-763.250000000000;
-762.650000000000];
y =[1;1.09300000000000;1.24200000000000;1.39900000000000;1.56400000000000;
1.73800000000000;1.92000000000000;2;2.11000000000000;2.31000000000000;
2.52000000000000;2.73900000000000;2.96800000000000;3;3.20800000000000;
3.45700000000000;3.71800000000000;3.99000000000000;4;4.27300000000000;
4.56700000000000;4.87400000000000;5;5.19300000000000;5.52400000000000;
5.86800000000000;6;6.22500000000000;6.59500000000000;6.97900000000000;
7;7.37600000000000;7.78830000000000;8;8.21500000000000;8.65600000000000;
9;9.11200000000000;9.58400000000000;10;10.0710000000000];
Total=[matrix1 matrix2];

Réponses (1)

Ben11
Ben11 le 26 Août 2014
Modifié(e) : Ben11 le 26 Août 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');
end
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 commentaire
Marcel Been
Marcel Been le 26 Août 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by