Picking exact data on a plot with ginput
Mostrar comentarios más antiguos
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?
Respuestas (1)
Adam Danz
el 25 de Oct. de 2019
1 voto
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 comentarios
Luigi Sambuelli
el 25 de Oct. de 2019
Adam Danz
el 25 de Oct. de 2019
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
el 25 de Oct. de 2019
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
el 25 de Oct. de 2019
If you can formalize the problem or perhaps map it out in a diagram I might be able to help further.
Adam Danz
el 28 de Oct. de 2019
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
el 28 de Oct. de 2019
________________________________________________
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
el 28 de Oct. de 2019
_______________________________________________
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
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
el 29 de Oct. de 2019
Adam Danz
el 29 de Oct. de 2019
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
el 30 de Oct. de 2019
Adam Danz
el 30 de Oct. de 2019
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
el 30 de Oct. de 2019
Adam Danz
el 30 de Oct. de 2019
Luigi Sambuelli
el 30 de Oct. de 2019
Categorías
Más información sobre Multirate Signal Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!