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: Phase_Ex_ZPPP.m
    path of file: ./repos/OSET/matlab/tools/eeg
    
    the code of the file until where you have to start completion: function [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs, varargin)
% 
% [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs)
% [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs, WS, max_f, ndft, pertnum)
% 
% *************************************************************************
% * Instantaneous Phase (IP) estimation using the Zer-Pole Perturbation   *
% * Phase estimation method (Z-PPP) [1] through analytic representation,  *
% * IIR filters and forward-backward filtering.                           *
% * >>> Refer to the User Guide for further details.                      *
% *************************************************************************

    
function [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs, varargin)
% 
% [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs)
% [phase, inst_freq, amp] = Phase_Ex_ZPPP(x1, fs, WS, max_f, ndft, pertnum)
% 
% *************************************************************************
% * Instantaneous Phase (IP) estimation using the Zer-Pole Perturbation   *
% * Phase estimation method (Z-PPP) [1] through analytic representation,  *
% * IIR filters and forward-backward filtering.                           *
% * >>> Refer to the User Guide for further details.                      *
% *************************************************************************
% 
%             Inputs:
%                       x1 : input signal
%                       fs : sampling frequency (Hz)
%            (optional) WS : Stop-band frequency (Hz) >> (BW = WS/2)
%            (optional) max_f : Maximum frequency to extract its
%                               corresponding phase information (the IPs
%                               will be estimated for frequency components
%                               from 1(Hz) to max_f(Hz)) *** Refer to
%                               User Guide for more details.
%            (optional) ndft: number of frequency bins
%            (optional) pertnum: number of attempts for perturbing filter's
%                                zeros and poles
% 
%             Defaults:
%                       WS = 1(Hz)
%                       max_f = 30(Hz)
%                       ndft = 100
%                       pertnum = 100
% 
%             *NOTE: While specifying a value to one of the parameters
%                    having default values, an empty bracket [] must be
%                    used for non-specified parameters. If you're not using
%                    these parameters, empty bracket is not required.
%             Outputs: 
%                       phase : Instantaneous Phase matrix for frequency
%                               components from 1(Hz) to max_f(Hz) ***
%                               Respectively from first to last ROWS.
%                       inst_freq : Instantaneous Frequency matrix for 
%                                   frequency components from 1(Hz) to 
%                                   max_f(Hz) *** Respectively from first 
%                                   to last ROWS.
%                       amp : Instantaneous Amplitude matrix for frequency
%                             components from 1(Hz) to max_f(Hz) ***
%                             Respectively from first to last ROWS. 
% 
% This program is provided by ESMAEIL SERAJ (esmaeil.seraj09@gmail.com).
% Please make sure to reference BOTH the original studies [1-2] and the 
% OSET [3] to help others find these items.
% 
%     [1] Esmaeil Seraj, Reza Sameni. ”Robust Electroencephalogram Phase 
%         Estimation with Applications in Brain-computer Interface Systems” 
%         Physiological Measurements (2017)
%     [2] Reza Sameni and Esmaeil Seraj, “A Robust Statistical Framework 
%         for Instantaneous Electroencephalogram Phase and Frequency 
%         Analysis” Physiological Measurements (2017)                     
%     [3] R. Sameni, The Open-Source Electrophysiological Toolbox (OSET), 
%         version 3.1 (2014). URL http://www.oset.ir
%         Released under the GNU General Public License
%         Copyright (C) 2012  Reza Sameni
%         Shiraz University, Shiraz, Iran
%         reza.sameni@gmail.com
% 
% 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 2 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, write to the
% Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
% MA  02110-1301, USA.
% 

%%-Checking inputs and assigning default values-%%
x1 = x1(:)';
if nargin<2
    error('***At Least the Sampling Frequency (Fs) Have to Be Specified***')
elseif nargin==2
    f = linspace(1/2, 1, 2);
    max_f = 30;
    ndft = 100;
    pertnum = 100;
elseif nargin>2
    if nargin~=6
        error('***An Empty Bracket [] Must be Used for the Values NOT Being Specified***')
    end