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

조회 수: 2 (최근 30일)
佳丽 周
佳丽 周 2022년 6월 8일
편집: Sam Chak 2022년 6월 8일
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