You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: qrsIntervals.m
    path of file: ./repos/cuffless-BP-estimation/Preprocessing
    
    the code of the file until where you have to start completion: function qrsIntervals(predata)
global data fs subject
% For each segment, crop into several windows containing one QRS complex
for s = 1 : size(predata.ecg, 2) % 'predata.ppg' and 'predata.abp' have the same length
    % Make R peaks more noticeable/detectable
    wt_ecg     = modwt(predata.ecg(:, s), 4, 'sym4');
    wt_ecg_rec = zeros(size(wt_ecg));
    
    % Select relevant coefficients
    wt_ecg_rec(2 : 3, :) = wt_ecg(2 : 3, :);
    
    % Reconstruct the signal
    ecg_rec = imodwt(wt_ecg_rec, 'sym4');

    
function qrsIntervals(predata)
global data fs subject
% For each segment, crop into several windows containing one QRS complex
for s = 1 : size(predata.ecg, 2) % 'predata.ppg' and 'predata.abp' have the same length
    % Make R peaks more noticeable/detectable
    wt_ecg     = modwt(predata.ecg(:, s), 4, 'sym4');
    wt_ecg_rec = zeros(size(wt_ecg));
    
    % Select relevant coefficients
    wt_ecg_rec(2 : 3, :) = wt_ecg(2 : 3, :);
    
    % Reconstruct the signal
    ecg_rec = imodwt(wt_ecg_rec, 'sym4');
    
    % Make peak detection and determine mean interval between R peaks for heart rate estimation
    [Rpeaks, Rlocs] = findpeaks(ecg_rec, 'MinPeakHeight', 3 * std(ecg_rec), 'MinPeakDistance', ceil(0.4 * fs));
    % Vector of length of time intervals between R peaks
    RR = Rlocs(2 : end