Extract Plot Values from Sine Wave

16 views (last 30 days)
katerina
katerina on 2 Oct 2014
Commented: katerina on 2 Oct 2014
Hello,
I'm looking for some general ideas / suggestions about my current problem. I need to write some functions that will extract interesting data points (min,max, p-p,etc) from a plotted sine wave. The wave has not been created yet. A coworker will create the equations that will generate this wave at a later date, so I don't know if he will be plotting an actual sine wave, or if he will have points that will become a wave form. So I cannot simply take values from a single equation. I hope that makes sense so far. Basically, I'm doing the post-processing work on his plot so that when he creates the equations and plots, the whole program will run, and my functions will appropriately extract the information needed. Does anyone have any suggestions on a stable way to extract interesting information as mentioned from a currently unknown plot? Or to even extract ALL values in defined timesteps?
It seems that there are so many ways to do something like this, so I'm hoping for some guidance to know which paths might be better than others. I will be creating test plots while doing this, but I cannot be sure of the end outcome, except that they will be sine waves.
  4 Comments
katerina
katerina on 2 Oct 2014
hahahahaha! - very good question. I work with all mechanical engineers, so most of them prefer to have minimal contact with script / function-writing.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 2 Oct 2014
You have to extract the entire data series from a plot. If you have the plot open in your workspace, the easiest way is to use the appropriate handle graphics calls:
xd = get(gca, 'XData');
yd = get(gca, 'YData');
and then analyse ‘xd’ and ‘yd’ as you wish.
  2 Comments
Star Strider
Star Strider on 2 Oct 2014
My pleasure!
Note: ‘plot open in your workspace’ means as a ‘.fig’ file. An image file will not have that information.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!