MATLAB: How to separate a signal into 4 second segments

ecgsignal segmentation

Lets say I have an ECG signal and I want to separate it 4 second segments. How to do it in MATLAB?
% MATLAB Code
load ('C:\Users\Explorer\Documents\MATLAB\PhysioNet_Database\Malignant_Ventricular_Ectopy_Database\418m.mat');
signal=val(1,:);
plot(signal)
xlabel('Time')
ylabel('Voltage')

Best Answer

If you have the signal processing toolbox, see buffer(), provided the signals are equally spaced in time.