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: svm_rfe.m
    path of file: ./repos/CanlabCore/CanlabCore/Statistics_tools
    
    the code of the file until where you have to start completion: function out = svm_rfe(dat, varargin)

% This function performs Recursive Feature Elimination (RFE) using
% 'predict' function for model training and cross-validation. It returns 
% details of each elimination step and a model trained on the number of 
% features that shows the best accuracy.
%
%
% :Features:
%       - repeatedly trains a desired model (SVM recommended) using the 'predict'
%       function and eliminates least significant weights until a desired
%       number of features is reached
%       - elimination step and target number of features can be defined by
%       user
%       - evaluates accuracy in each iteration based on CV error
%
%
% :Usage:
%       out = svm_rfe(dat, varargin)
%
%
% :Input variables:
%       **n_removal**
%           The number of features to be removed in each iteration. Default
%           is 10000.
%           e.g., 'n_removal', 15000
%
%       **n_finalfeat**
%           The final number of features after elimination. Default is
%           50000.
%           e.g., 'n_finalfeat', 30000
%
%       **n_initialfeat**
%           The number of features, from which the algorithm starts the elimination
%           by the defined step. The excessive features are eliminated in one step.
%           Default is the whole feature set.
%           e.g., 'n_initialfeat', 100000
%
%       **for other inputs see fmri_data.predict
%
% :Example:
%
%       out = svm_rfe(dat, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr');
%       out = svm_rfe(dat, 'n_finalfeat', 30000, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr);
%       out = svm_rfe(dat, 'n_removal', 12000, 'n_finalfeat', 30000, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr');
%       out = svm
    
function and eliminates least significant weights until a desired
%       number of features is reached
%       - elimination step and target number of features can be defined by
%       user
%       - evaluates accuracy in each iteration based on CV error
%
%
% :Usage:
%       out = svm_rfe(dat, varargin)
%
%
% :Input variables:
%       **n_removal**
%           The number of features to be removed in each iteration. Default
%           is 10000.
%           e.g., 'n_removal', 15000
%
%       **n_finalfeat**
%           The final number of features after elimination. Default is
%           50000.
%           e.g., 'n_finalfeat', 30000
%
%       **n_initialfeat**
%           The number of features, from which the algorithm starts the elimination
%           by the defined step. The excessive features are eliminated in one step.
%           Default is the whole feature set.
%           e.g., 'n_initialfeat', 100000
%
%       **for other inputs see fmri_data.predict
%
% :Example:
%
%       out = svm_rfe(dat, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr');
%       out = svm_rfe(dat, 'n_finalfeat', 30000, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr);
%       out = svm_rfe(dat, 'n_removal', 12000, 'n_finalfeat', 30000, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr');
%       out = svm_rfe(dat, 'n_removal', 12000, 'n_finalfeat', 30000, 'n_initialfeat', 150000, 'algorithm_name', 'cv_svm', 'nfolds', 5, 'error_type', 'mcr');
%
%
% Created by Lada Kohoutova (ladakohoutova@gmail.com)
%            Cocoan lab (Wani Woo's lab), 2/19/2019
%

% default

n_removal = 10000;
n_finalfeat = 50000;
init_feat = 0;

for i = 1:length(varargin)
    if ischar(varargin{i})
        switch varargin{i}
            % functional commands
            case 'n_removal'
                n_removal = varargin{i+1};
                varargin{i+1} = [];
            case 'n_finalfeat'
                n_finalfeat = varargin{i+1};
                varargin{i+1} = [];
            case 'n_initialfeat'
                n_initialfeat = varargin{i+1};
                init_feat = 1;
                varargin{i+1} = [];
        end