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: spm_dcm_peb_to_gcm.m
    path of file: ./repos/spm
    
    the code of the file until where you have to start completion: function [GCM,PEB] = spm_dcm_peb_to_gcm(PEB, GCM_template, options)
% Generate an array of DCMs based on parameters from a PEB model
% FORMAT [GCM,PEB] = spm_dcm_peb_to_gcm(PEB, GCM_template, options)
% 
% Any parameters not included in the PEB model will be fixed at their 
% prior means (alternative fixed values can be selected).
%
% -------------------------------------------------------------------------
% Inputs:
%
% PEB - PEB model containing at least the following fields:
%
%                PEB.Ep   - group level parameter means
% 
%                PEB.Pind - indices within the DCM of parameters included
%                           in the PEB.
%
%                PEB.beta - between-subjects variance for each parameter is
%                           set to a fraction of the within-subject DCM
%                           priors: GCM_template{x}.M.pC / beta
%

    
function [GCM,PEB] = spm_dcm_peb_to_gcm(PEB, GCM_template, options)
% Generate an array of DCMs based on parameters from a PEB model
% FORMAT [GCM,PEB] = spm_dcm_peb_to_gcm(PEB, GCM_template, options)
% 
% Any parameters not included in the PEB model will be fixed at their 
% prior means (alternative fixed values can be selected).
%
% -------------------------------------------------------------------------
% Inputs:
%
% PEB - PEB model containing at least the following fields:
%
%                PEB.Ep   - group level parameter means
% 
%                PEB.Pind - indices within the DCM of parameters included
%                           in the PEB.
%
%                PEB.beta - between-subjects variance for each parameter is
%                           set to a fraction of the within-subject DCM
%                           priors: GCM_template{x}.M.pC / beta
%
%                PEB.Ce   - alternatively, a between-subjects covariance
%                           matrix can be provided, in which case beta is 
%                           ignored
%
% GCM_template - cell array of dimension [1 x models], where each element
%                is a DCM. These DCMs provide the structure of the models
%                that will be simulated (so don't need to be estimated).
%
%                If any parameters are not included in the PEB, they will
%                be fixed at values in GCM_template{m}.Ep. If this is not
%                present, they will be fixed at the priors in
%                GCM_template.M.pE{1}.
%
%                Alternatively, a matrix of size [subjects x models] can be
%                given, allowing subject-specific values for parameters not
%                in included in the PEB.
%
% options - settings structure for the simulation with fields:
%
%           options.nsubjects - number of subjects to generate
%
%           options.ratio - the ratio of posterior:prior covariance for
%                           the PEB model. [default 2]
%
% Returns:
%
% GCM  - DCM array populated with simulated data
% PEB  - PEB structure updated with PEB.Ce if not already present
%__________________________________________________________________________

% Peter Zeidman
% Copyright (C) 2016-2022 Wellcome Centre for Human Neuroimaging


% Set defaults
try options.gen_idx;   catch, options.gen_idx = 1; end