How do i get x value from Y input from matlab polynomial plot

Hi, I plotted a graph, and i would like to get the x value for a given y. here are the codes for it. To be specific, i would like to know the X value at 10%of the max value of Y. After runnign the code, i got for 10% of Y is 19.32231. so i want to know what is the corresponding x value from the graph
x = 0:0.1:7 y= -0.0025*x.^6 + 0.0483*x.^5 - 0.177*x.^4 + 0.0122*x.^3 - 6.2034*x.^2 + 2.6569*x + 192.94; y2= -0.0032*x.^6 + 0.0305*x.^5 + 0.1034*x.^4 - 0.469*x.^3 - 8.3568*x.^2 + 2.7083*x + 171.01;
plot(x,y); hold on plot(x,y2);
maxY=max(y); maxY2=max(y2);

 採用された回答

Star Strider
Star Strider 2014 年 3 月 5 日

0 投票

I suggest using interp1:
maxY=max(y);
maxY2=max(y2);
y_10 = 0.1*maxY;
y2_10 = 0.1*maxY2;
xi = interp1(y,x,y_10)
x2i = interp1(y2,x,y2_10)
plot(x,y, xi,y_10,'+r');
hold on
plot(x,y2, x2i,y2_10,'+r');
hold off

2 件のコメント

FAISAL
FAISAL 2014 年 3 月 6 日
Thanks! it works handsomely!
Star Strider
Star Strider 2014 年 3 月 6 日
My pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2014 年 3 月 5 日

0 投票

Use matlab's 'roots' function to solve equation:
-0.0025*x.^6 + 0.0483*x.^5 ..... + 2.6569*x + 192.94 - maxY = 0
and select the appropriate root out of six possibilities. (You can refer to your plot for the latter.)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by