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: FIND_in_phase_samples.m
    path of file: ./repos/OSET/matlab/tools/ecg
    
    the code of the file until where you have to start completion: function [T0,T1] = find_in_phase_samples(peaks,phase)

L = length(peaks); % the signal length
rr_intervals = diff(find(peaks)); % the RR-intervals
% Avg, Min and Max RR-intervals
avg_rr_interval = round(mean(rr_intervals));
min_rr_interval = min(rr_intervals);

    
function [T0,T1] = find_in_phase_samples(peaks,phase)

L = length(peaks); % the signal length
rr_intervals = diff(find(peaks)); % the RR-intervals
% Avg, Min and Max RR-intervals
avg_rr_interval = round(mean(rr_intervals));
min_rr_interval = min(rr_intervals);
max_rr_interval = max(rr_intervals);

wlen = max_rr_interval - min_rr_interval;

T1 = zeros(1,L - avg_rr_interval - wlen);
NN = length(T1);
for t = 1 : NN
    search_window_start = max(t + avg_rr_interval - wlen, 1);
    search_window_end