How to find x value for certain y value of a lineplot in matlab

2 次查看(过去 30 天)
I want to get EV value at P=50% without real data point at P=0.5 in the lineplot.
  1 个评论
佳丽 周
佳丽 周 2022-6-8
EV=[-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
P=[0.0312500000000000,0,0.0312500000000000,0.0156250000000000,0.00625000000000000,0.0208333333333333,0.0186011904761905,0.0429687500000000,0.0282118055555556,0.0312500000000000,0.0539772727272727,0.0758838383838384,0.130080856643357,0.158545100732601,0.256227106227106,0.439955357142857,0.648752289377290,0.705156822344322,0.740785256410257,0.809659090909091,0.869444444444444,0.903125000000000,0.912946428571429,0.949218750000000,0.971726190476191,0.989583333333333,0.987500000000000,0.992187500000000,0.968750000000000,1,1]

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2022-6-8
EV = EV(5:14);
P = P(5:14);
EV_05 = interp1(P,EV,0.5)
  7 个评论
Torsten
Torsten 2022-6-8
Explanation: You have to choose an interval for P where the values are monotonically increasing. Otherwise, you'll get NaN from the interpolation. Since this is not the case for your complete P vector, I only took the values from P(10) to P(20).
佳丽 周
佳丽 周 2022-6-8
Before posting online, I tried to fit a linear equation according to the nearest two data points. But I didn't get what I want proprely. May be chose a larger interval will be better fit my data.Thanks for your good explanation!

请先登录,再进行评论。

更多回答(2 个)

SALAH ALRABEEI
SALAH ALRABEEI 2022-6-8
You can find the the EV from the index of p value.
Example;
a=[4,2,3,5,6,7]
a = 1×6
4 2 3 5 6 7
b = a.^2
b = 1×6
16 4 9 25 36 49
Now, to find what is a at b= 9!
inx = find(b==9);
a(inx)
ans = 3
  2 个评论
佳丽 周
佳丽 周 2022-6-8
Thanks,but it doesn't work for my data.In your example,I want to find specific "a" value when b' doesn't exist in real ”b“.
Sam Chak
Sam Chak 2022-6-8
If the specific data and governing equation are unavailable, then you can only rely on Interpolation and Approximation Theory to find out the value.
More importantly, can you furnish the 17 visible data points (EV, P) for one-step further investigation of your NaN result?

请先登录,再进行评论。


Sam Chak
Sam Chak 2022-6-8
No joke, but this is the graphical approach.
  2 个评论
佳丽 周
佳丽 周 2022-6-8
Okk! I got what your meaning.Interpolation work for my data finally.Your graph is pretty straightforward and cute.Thanks for your assitance
Sam Chak
Sam Chak 2022-6-8
编辑:Sam Chak 2022-6-8
Cute? Vote if you think it is cute, but I guess you are probably cuter, Ms. Zhou 😊

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by