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: CBIG_ASDf_getBootstrappedSamples.m
    path of file: ./repos/CBIG/stable_projects/disorder_subtypes/Tang2020_ASDFactors/step3_analyses/bootstrapping
    
    the code of the file until where you have to start completion: function CBIG_ASDf_getBootstrappedSamples(output_dir, N)
% CBIG_ASDf_getBootstrappedSamples(output_dir, N)
% 
% Wrapper function to perform bootstrapping on ABIDE-II+GENDAAR ASD
% participants.
%
% Input:
%     - output_dir:
%            Absolute path to output directory where the results will be
%            saved
%     - N:
%            Interger, number of bootstrapped resamples
% 
% Example:
%       CBIG_ASDf_getBootstrappedSamples_wrapper('~/Temporary/bootstrapping', 100)
% 
%  Written by Siyi Tang and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

% Define path
CBIG_REPDATA_DIR = getenv('CBIG_REPDATA_DIR');
UNIT_TEST_DIR = fullfile(CBIG_REPDATA_DIR,'stable_projects','disorder_subtypes','Tang2020_ASDFactors');
sub_info = fullfile(UNIT_TEST_DIR,'data','subInfo_654.csv');
zScore_dir = fullfile(UNIT_TEST_DIR,'results','FC2doc','step1_output_zScores.mat');

% Add path
CBIG_CODE_DIR = getenv('CBIG_CODE_DIR');
CODE_DIR = fullfile(CBIG_CODE_DIR,'stable_projects','disorder_subtypes','Tang2020_ASDFactors');
addpath(fullfile(CODE_DIR,'step3_analyses','utilities'));

% Set random seed
rng('default');

% Get diagnosis info
[~, id_dx] = CBIG_ASDf_getSubData(sub_info);
dx = cell2mat(id_dx(:,2));

    
function CBIG_ASDf_getBootstrappedSamples(output_dir, N)
% CBIG_ASDf_getBootstrappedSamples(output_dir, N)
% 
% Wrapper function to perform bootstrapping on ABIDE-II+GENDAAR ASD
% participants.
%
% Input:
%     - output_dir:
%            Absolute path to output directory where the results will be
%            saved
%     - N:
%            Interger, number of bootstrapped resamples
% 
% Example:
%       CBIG_ASDf_getBootstrappedSamples_wrapper('~/Temporary/bootstrapping', 100)
% 
%  Written by Siyi Tang and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

% Define path
CBIG_REPDATA_DIR = getenv('CBIG_REPDATA_DIR');
UNIT_TEST_DIR = fullfile(CBIG_REPDATA_DIR,'stable_projects','disorder_subtypes','Tang2020_ASDFactors');
sub_info = fullfile(UNIT_TEST_DIR,'data','subInfo_654.csv');
zScore_dir = fullfile(UNIT_TEST_DIR,'results','FC2doc','step1_output_zScores.mat');

% Add path
CBIG_CODE_DIR = getenv('CBIG_CODE_DIR');
CODE_DIR = fullfile(CBIG_CODE_DIR,'stable_projects','disorder_subtypes','Tang2020_ASDFactors');
addpath(fullfile(CODE_DIR,'step3_analyses','utilities'));

% Set random seed
rng('default');

% Get diagnosis info
[~, id_dx] = CBIG_ASDf_getSubData(sub_info);
dx = cell2mat(id_dx(:,2));

% Load z scores
load(zScore_dir); % variables: z & discretized_z
z_discret = discretized_z(dx==1,:);
z = z(dx==1,:);
n_sub = size(z_discret,1);

for i = 1:N
    fprintf('====%d-th Resamples====\n', i);
    indices = randsample(n_sub, n_sub, true); % re-sample with replacement
    z_disc_resampled = z_discret(indices,:);
    z_resampled = z(indices,:);
    curr_dir = [output_dir '/resampled_' num2str(i)];
    mkdir(curr_dir);
    save([curr_dir '/zScores.mat'], 'z_disc_resampled', 'z_resampled');
    
    % Write into doc
    fileID = fopen([curr_dir '/dx1.dat'], 'w'); % clear contents
    fileID = fopen([curr_dir '/dx1.dat'], 'a'); % start append