Picking exact data on a plot with ginput
13 次查看(过去 30 天)
显示 更早的评论
I plot a line with experimental data (x,y). Then I want to pick, with ginput, EXACTLY, some of the data on the graph. Is it possible? How can be done?
回答(1 个)
Adam Danz
2019-10-25
See this answer. It shows two methods of obtaining the coordinates of a data point by clicking on it. The ginput() idea is explained in method #2. If you have any other quesitons, feel free to comment here (or in that link).
15 个评论
Luigi Sambuelli
2019-10-25
Thank you, i really did skrew my problem following this suggestion. But...
Luigi
Adam Danz
2019-10-25
Sorry, I didn't understand. Did you come across a new problem or is there a problem with the implementation of the proposed solution? I'd be glad to help out.
Adam Danz
2019-10-25
Luigi Sambuelli 's answer moved here as a comment.
MMM sorry, I was "obscure". I need to find some points on a graph (that have to be some of the "experimental points" used to make the graph) in order to calculate a detrending broken line (detrend command does not work because the signal is "unbalanced" around zero, yet nearly periodic). The point is that I do not know in advance how many points I will select to build these detrending lines... It's a messy problem..
Thank you anyway for your suggestion.
Luigi
Adam Danz
2019-10-25
If you can formalize the problem or perhaps map it out in a diagram I might be able to help further.
Adam Danz
2019-10-28
Thank you Adam for your efforts. In the attached figure you'll see some of the signals I've to detrend. Thank you anyway.
Luigi

Adam Danz
2019-10-28
________________________________________________
In your original quesiton, you wanted to use ginput() to choose a datapoint on the graph and it looks like you're trying to determine where your two datasets start to bifurcate. Is this still your goal?
It's unclear whether you're still seeking help on this topic. If you are, I'd be glad to help but I need to understand exactly what the goal is.
Adam Danz
2019-10-28
_______________________________________________
The two signal in the figure are measured independently by two sensors in two different places. Both of them have a drift (that sometimes is a broken line, not a straight line fron the beginning to the end). Each drift is different from the others. I'm trying to remove these dirfts. The matlab DETREND command does not work in this case because, searching for the liast square interpolating line, it works badly with signals that "have no zero mean around their linear trend". In this case the interpolating line takes into account the minima. My idea is to pick 2 points in the linear parts of the graphs, calculate a straight line passing in these two points and subtract this straight line to the original data. In fact the linear part in the signals shoul be horizontal i.e. have a costant value. That's why I was looking for a way to pick exactly two data points.
LS
Adam Danz
2019-10-28
编辑:Adam Danz
2019-10-28
Hmmm I've never used detrend() but I took a look at that documentation and does seem like it would be the function to use in this problem.
Your idea to pick 2 points in the linear parts of the graph is subjective and therefore not generalizable to other sets of data. Instead, have you tried using the "break point" (bp) option in detrend()? y = detrend(x,n,bp)
"DETREND command does not work in this case because, searching for the liast square interpolating line, it works badly with signals that "have no zero mean around their linear trend""
Would you happen to have a plot that shows the results along with whatever input options you used in detrend()? I'm curious what "works badly" looks like.
Please use the link below that reads "Comment on this Answer" unless you are proposing a solution to your question.
Luigi Sambuelli
2019-10-29
Here two signals: before and after detrend. An offset is clearly visible. In my opinion it comes from
y = detrend(x) removes the best straight-line fit
and it does this even if you select 2 or 3 break points between each consecutive couple of points.
Adam Danz
2019-10-29
One possibility is that the trend isn't linear. The slope of the 2nd rise in your black data seems to be slightly larger than the slope in the 1st rise.
My first suggestion would be to try to optimize your detrend() inputs. What breakpoints did you use?
My 2nd suggestion would be to break up your data into two segments: 1) all data prior to the the jump-up at around the 1st week of Feb 2018 and 2) data the follow that point; and then to run detrend on each segment of data.
Luigi Sambuelli
2019-10-30
Indeed I selected 2 break points (bp) obtaining 3 interpolating lines: one before the first bp, the second between the 2 bp and the 3 bp and the last from the 3 bp to the end of the signal. But, as you wriote (and I agree absolutely with you) the choice of the break point are "empirical". I'm afraid that this is a kind of "hill posed" problem. Thank you very much for the time you spent around my stuff.
Adam Danz
2019-10-30
No problem - I enjoy it ;)
Depending on how much time you have to play around with the data, you might try breaking up the data into ~3 segments and applying detrend() to each, and then stitch them back together.

Luigi Sambuelli
2019-10-30
Yeah this is exactly what I've been doing for the last 2 or 3 weeks :-)
Thank you very much again.
Luigi
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
