How do i get x value from Y input from matlab polynomial plot
Show older comments
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);
Accepted Answer
More Answers (1)
Roger Stafford
on 5 Mar 2014
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.)
Categories
Find more on Line Plots 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!