I have a plot.For each increment of 1 in x value I have y value. But I need y values for 0.1 increment in x-axis. How can I extract this from the plot itself.Please help me.

3 件のコメント

Walter Roberson
Walter Roberson 2015 年 11 月 2 日
What form is the plot in? Is a .jpg? Is it a .fig? Is it currently displayed as graphics in MATLAB? If it is currently being displayed in MATLAB, is there a reason why you cannot perform calculations based on the data that was used to create the plot, without having to go through the extra step of retrieving that data from the plot?
anna lakshmi
anna lakshmi 2015 年 11 月 2 日
The plot is generated in matlab. Actually I am plotting the graph. But I have values on x-axis with increment of 1. But for calculations I need increments in 0.1 I want the values from the plot itself. Help me how to find it. Actually I am calculating the width at 205 in y axis. For that I need corresponding x-axis values which should be in point values.
Walter Roberson
Walter Roberson 2015 年 11 月 2 日
Analogy:
Suppose it is your practice to start with a couple of pieces of paper and a box, and you throw the pieces of paper in the box and then you ask me to get the pieces of paper out of the box and do something with them. And my question is "Why can't I have the pieces of paper before you throw them in the box?"
newx = min(x):0.1:max(x);
newy = interp1(x, y, newx);
I think you will find that somewhat easier than getting the values "from the plot itself"...
x205left = newx(find(newy>=205, 1, 'first'));
x205right = newx(find(newy<=205, 1, 'last'));
width205 = x205right - x205left

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

回答 (1 件)

dpb
dpb 2015 年 11 月 2 日
編集済み: dpb 2015 年 11 月 2 日

0 投票

Alternately to Walter's solution based on interpolation to a particular resolution, solve directly for the locations wanted rather than simply the chosen 0.1 approximation resolution --
>> y=600*normpdf(-3:0.4:3,0,1); % some dummy data that approximates yours as a peak
>> ix=find(abs([0 diff(y>205)])==1); % find the two crossings of interest
>> x205left=interp1(y(1:ix(1)),1:ix(1),205)
x205left =
7.1460
>> x205right=interp1(y(ix(2)-1:end),ix(2)-1:length(y),205)
x205right =
9.8540
>>
Can also use Walter's find to locate the two initial positions, I just illustrated another useful technique for location positions in curves that's extremely useful on occasion albeit not "quite so much" here as there are only two points.
Only real "trick" here is that must do the interp1 call on the two regions as it will only handle strictly increasing/decreasing patterns whereas the full curve is double valued in x.
The other option in the above is that you can also use either higher-ordered or perhaps spline interpolation to perhaps better approximate the underlying curve--this could be evaluated for the example above where the exact solution is available for comparison.

カテゴリ

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

タグ

質問済み:

2015 年 11 月 2 日

編集済み:

dpb
2015 年 11 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by