Question about finding y value for certain x value of a plot
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hello, I have a question about data cursor. My data plot gives me a data cursor which goes by 0.5 for the x-axis values.
For example, when i move the curse right side, it goes like 0.5, 1.0, 1.5, 2.0...
Say I want to know the y-value at the x-value of 5.1
I guess the most simple way is to zoom in and see the value, but there are about 1 thousand data to work with.
Therefore, I want to give a commend that orders to give the y-value at certain x-value. If there isn't a data set, it would be nice to get the value of how the plot line is drawn for the points...(interpolation etc..)
How can I do that?
Accepted Answer
Ilham Hardy
on 25 Jan 2016
If you have your plot data,
desiredY = interp1(yourXaxisdata,yourYaxisdata,certainX);
10 Comments
yc j
on 25 Jan 2016
OMG!!! this is amazing!!!!!!!!!! Thank you so much!
One more question, How can I get 'desiredY' for decimal to say.. 8?
For example, it's giving me the rounded disiredY value of 0.0042, not 0.0041882
format longg
MATLAB displays to four decimal places by default, but using the command format you can change how values are displayed. Read that link I gave, have a look at some of the possible format options (there is a table at the bottom), and try some with your data.
yc j
on 25 Jan 2016
thank you very much!! this means a lot to me!!
SANGEERTH P
on 15 Jan 2020
Thank you sir.
this works and is amazing
Joao Gocan
on 10 Feb 2021
That solves my problem! Thank you!
Feroz Mulani
on 10 Mar 2021
If i want to find a value say e.g value of x at function y = 1, then how should i write.
Sara Nasir
on 9 Mar 2022
You can interchange x and y in the interp1 command to get the desired output values.
Florina-Iuliana TUDOR
on 10 Mar 2022
Hi, I have kind of the same problem, i made a plot using excel data and i want to see the y value for some x values that are not from the data tabel, how can i do that?
Torsten
on 10 Mar 2022
If X and Y are your data arrays and Xq are your query points, use
Yq = interp1(X,Y,Xq);
Ganesh P. Prajapat
on 21 Jan 2023
Yas, it works perfectly. Thnak you
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)