How to extract X value given Y value from graph.

154 views (last 30 days)
I have a graph which I ploted from X and Y values. X and Y are the data vectors. Now I wnted to find values of X corresponding to perticular value of y.
X=[0.00163629165319779 0.00919798132258265 0.0108887716090971 0.0146711509895121 0.0170727875027912 0.0183195248019579 0.0214701529053916 0.0429751397974718 0.0492808450276714 0.0535887468601313 0.0546312668441853 0.108838368209090 0.123117548287373 0.126309277779226 0.133652225605413 0.138726746967278 0.176380030642817 0.178656767960438 0.181244974266293 0.182028488504125 0.188366079912920 0.204276265010833 0.205419462095058 0.206611392842045 0.219575407312163 0.230076938132872 0.231822979086683 0.232631056161634 0.237634467232773 0.242104610234617 0.267542565734243 0.281557956744304 0.312833057094883 0.319124464220357 0.343375832711649 0.348289420385577 0.352569636089163 0.357642593625700 0.360188336139401 0.374263685881673 0.390056224874232 0.391650522675869 0.392413301822307 0.392906376647038 0.398112256101353 0.404497829354034 0.408989317941850 0.413270285981264 0.440717991244140 0.442788702297138 0.466238670974959 0.478229661633876 0.506778136096007 0.516813401433934 0.539005985379619 0.554907031467319 0.555940863634276 0.594998712090185 0.624358289172818 0.636691646673399 0.636691646673399 0.636691646673399 0.636691646673399 0.636691646673399 0.673595576899095 0.690991870967221 0.691623728204757 0.694482327270088 0.703223226864390 0.713125941582075 0.729095502236721 0.749453251696249 0.785248184904319 0.790012531082956 0.815065416646928 0.821315922015482 0.826164341954818 0.829691396788946 0.841734834718935 0.854822741928195 0.858109043192997 0.891859889006936 0.906733683367389 0.952764915345216 0.952764915345216 0.952764915345216 0.980470366913377 0.995725305844472 1.02965375760247 1.09116894860735 1.10670509719372 1.11422792999389 1.12127930245400 1.12127930245400 1.12334033118983 1.14277471093836 1.16917633244481 1.19089850966396 1.33264717043745 1.34901320716680 1.36779787738210 1.44087981077227 1.64523008957909 1.64791868775681 2.27643402946012 2.40045676947028 2.45142678398700]
Y=[0.327970660780512 0.332011235759306 0.332921494603458 0.334966833639170 0.336272047142938 0.336951613545687 0.338675071601992 0.350676523995197 0.354275568517746 0.356755561062934 0.357358328092331 0.390144287739127 0.399270422133906 0.401339342218769 0.406139930184248 0.409491004458485 0.435235365455767 0.436842919676984 0.438677608063090 0.439234531651005 0.443765372470964 0.455346819396008 0.456190529354724 0.457071870791561 0.466768441997315 0.474773779922694 0.476118038978851 0.476741456944862 0.480619720732729 0.484111312757906 0.504469097848463 0.516049003307847 0.542856789444626 0.548415510596634 0.570380400825788 0.574936780624634 0.578935485718932 0.583710823819502 0.586122035838970 0.599634471364500 0.615166607306969 0.616756803237560 0.617519073048832 0.618012319891502 0.623244115538772 0.629721998108256 0.634318708785900 0.638731195373301 0.667760657214304 0.670003487282225 0.695934458307588 0.709579482217070 0.743152374382388 0.755327344275103 0.782964775513683 0.803386803712655 0.804732868698833 0.857273337746951 0.899014193321375 0.917149276210161 0.917149276210161 0.917149276210161 0.917149276210161 0.917149276210161 0.973627548017118 1.00144444463865 1.00246961429251 1.00712073630011 1.02147703708904 1.03798894692457 1.06518092762530 1.10088015869719 1.16657580257029 1.17561063999175 1.22428363044642 1.23673808159782 1.24648599430674 1.25362549978489 1.27831360124910 1.30569436282117 1.31266115228447 1.38639837317600 1.42019536561643 1.53009968474307 1.53009968474307 1.53009968474307 1.60030840865775 1.64033208407164 1.73297416779503 1.91448899911085 1.96326411840361 1.98732634282930 2.01014827313001 2.01014827313001 2.01686820351132 2.08134856950608 2.17226025957346 2.25002870512480 2.83056628811592 2.90658351414197 2.99635450885091 3.37278249763301 4.69567928252034 4.71616719791340 13.0495320257110 15.9519723894339 17.3244414235913]
how to find value of X at Y=15? y=15 is not available in Y vector. kindly help me to write a code. Thanks

Accepted Answer

KSSV
KSSV on 8 May 2020
[Y,idx] = unique(Y) ;
X = X(idx) ;
iwant = interp1(Y,X,15)

More Answers (1)

Rik
Rik on 8 May 2020
You can treat x as y and y as x. That way you can use normal interpolation and curve fitting tools.
  3 Comments
Govind Kumar
Govind Kumar on 8 May 2020
Edited: Govind Kumar on 8 May 2020
No I can't use curve fitting tool. I have to use this code on loop. Can you goe me code for interploation?
Govind Kumar
Govind Kumar on 8 May 2020
From fig I can see for Y=8 x will be approx 2. So is their any method so I can extract excact value by code

Sign in to comment.

Categories

Find more on Graph and Network Algorithms 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!