How would one go about trimming a matrix graphically?

4 次查看(过去 30 天)
I have multiple large datasets (doesn't everyone) that I need to figure out a quicker way of "trimming" before post processing. I need to keep the original dataset unaltered, but each of these datasets has a variable that was changed multiple times during the recording. Each dataset has the first column being time and then another twenty or so columns of sensor data. For each of these datasets, I would like to quickly plot a single column of data versus time, select a timeframe of data that has reached steady state and then save the "trimmed" dataset as a new matrix.

采纳的回答

Renee Coetsee
Renee Coetsee 2017-3-23
You could accomplish this using the 'KeyPressFcn' figure callback:
When you click on the figure, you can plot a vertical line at that location. The x value of that line (which can be accessed from the line's properties) will correspond to the last (or first) value that you would like in the data matrix. You could use a button, which when pressed, will 1) duplicate the matrix, as to not modify the original 2) find the first occurrence x-value in the matrix 3) delete all elements after that x-value.
I hope these steps will help! Depending on your data, the first occurrence of an x-value may be before you want to trim. In this case, you can try finding the approximate index of the line using the line's position relative to the length of the axes.
  1 个评论
Richard Wanat
Richard Wanat 2017-5-25
Sorry for the delay. I was not familiar with KeyPressFCN, but this did spawn an idea. Using GUIDE, I made a simple data input GUI that plotted multiple variables that may have changed during the logging (I had four being plotted at a time). Using the GUI, I could manually enter the location of two vertical bars (cursors) to "trim" between. I would have preferred to graphically drag the bars, but hey, it worked.
Unfortunately, there is too much IP in the code to post, but the one critical thing I needed to do was pass variables through global variables (filename, suffix, cursor locations, etc.).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by