Expert Answer
Kshitij Singh answered .
2025-11-20
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
Not satisfied with the answer ?? ASK NOW