How can I use the markers in SPTOOL to crop and save portions of my signal in the Signal Processing Toolbox 6.2 (R14)?

8 views (last 30 days)
I am using SPTOOL to graphically view my signal. I would like to use the vertical markers to crop and save portions of my signal.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to crop and save portions of a signal using the vertical markers in SPTOOL is not available in the Signal Processing Toolbox 6.2 (R14).
To work around this issue, try exporting the position of the markers from the Signal Browser, determining the corresponding indices of the data that constitutes the signal, and using the indices to generate a cropped signal. The following example demonstrates this approach using the "train" signal that ships with MATLAB:
1. Type the following at the MATLAB prompt to load a sample signal in the workspace and start SPTool:
load train
sptool
2. Choose "train" and select "View" under the signals portion of the SPTool startup window.
3. Position the markers in the main display area of the Signal Browser window.
4. Select Markers -> Export... and enter "marker_struct" as the name of the marker structure to be saved in the workspace.
5. Issue the following at the MATLAB prompt to crop and save the portion of the signal demarcated by the markers:
max_time = length(y)/Fs;
index_1 = round(marker_struct.x1/max_time * (length(y)-1)+1);
index_2 = round(marker_struct.x2/max_time * (length(y)-1)+1);
cropped_signal = y(index_1:index_2);
save myfilename cropped_signal Fs

More Answers (0)

Community Treasure Hunt

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

Start Hunting!