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: pulse_onsets_from_peaks.m
    path of file: ./repos/ppg-beats/source
    
    the code of the file until where you have to start completion: function onsets = pulse_onsets_from_peaks(sig, peaks)
% PULSE_ONSETS_FROM_PEAKS  Identifies pulse onsets.
%   PULSE_ONSETS_FROM_PEAKS detects pulse onsets in a photoplethysmogram 
%   (PPG) signal from the locations of the pulse peaks
%   
%   # Inputs
%   
%   * sig : a vector of PPG values
%   * peaks : indices of detected pulse peaks
%   
%   # Outputs
%   * onsets : indices of detected pulse onsets
%   
%   # Author
%   Peter H. Charlton, University of Cambridge, February 2022
%   
%   # Documentation
%   <https://ppg-beats.readthedocs.io/>
%   
%   # Version

    
function onsets = pulse_onsets_from_peaks(sig, peaks)
% PULSE_ONSETS_FROM_PEAKS  Identifies pulse onsets.
%   PULSE_ONSETS_FROM_PEAKS detects pulse onsets in a photoplethysmogram 
%   (PPG) signal from the locations of the pulse peaks
%   
%   # Inputs
%   
%   * sig : a vector of PPG values
%   * peaks : indices of detected pulse peaks
%   
%   # Outputs
%   * onsets : indices of detected pulse onsets
%   
%   # Author
%   Peter H. Charlton, University of Cambridge, February 2022
%   
%   # Documentation
%   <https://ppg-beats.readthedocs.io/>
%   
%   # Version
%   1.0
%   
%   # License - GPL-3.0
%      Copyright (c) 2022 Peter H. Charlton
%      This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
%      This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
%      You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

onsets = nan(length(peaks)-1,1);
for wave_no = 1 : length(peaks)-1
    [~, temp] = min(sig(peaks(wave_no):peaks(wave_no+1)));
    onsets(wave_no) = temp + peaks(wave_no) - 1;
end