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: designsim.m
    path of file: ./repos/CanlabCore/CanlabCore/OptimizeDesign11/GA3/georges_tourtellot
    
    the code of the file until where you have to start completion: function [t,conse,allt,glm] = designsim(noisetype,dmodel,HRF,ISI,TR,noise_var,c,beta,S,varargin)
% function [t,modelse,allt,glm] = designsim(noisetype,dmodel,HRF,ISI,TR,noise_var,c,betas,S,xcfunction [if using 'myxc'],num2avgover)
%  [t,modelse,allt,glm] = designsim('myxc',M.modelatTR,HRF,ISI,TR,noise_var,c,beta,fullS,xc)
%
% noisetype:
%   '1overf' : use Luis Hernandez' 1/f model with your specified noise variance
%   'myxc'   : use your own autocorrelation function and noise variance
%
% model = matrix of regressors (cols) sampled at frequency of ISI

    
function [t,conse,allt,glm] = designsim(noisetype,dmodel,HRF,ISI,TR,noise_var,c,beta,S,varargin)
% function [t,modelse,allt,glm] = designsim(noisetype,dmodel,HRF,ISI,TR,noise_var,c,betas,S,xcfunction [if using 'myxc'],num2avgover)
%  [t,modelse,allt,glm] = designsim('myxc',M.modelatTR,HRF,ISI,TR,noise_var,c,beta,fullS,xc)
%
% noisetype:
%   '1overf' : use Luis Hernandez' 1/f model with your specified noise variance
%   'myxc'   : use your own autocorrelation function and noise variance
%
% model = matrix of regressors (cols) sampled at frequency of ISI
% noise_var = variance of 1/f noise from your scanner
% c = a contrast across the regressors
% beta = a list of betas to test
%   each beta should be a row vector, and you can have multiple rows
%
% S: smoothing matrix, or 0 for no smoothing.
% _______________________________________________________________________
% Output is a distribution of t-scores in a vector and the maximum correlation between predictors
% t-scores are in a column vector, one for each set of betas.
%
% Special mode: if 4 output arguments specified, 'plot mode'.  Produces graph and extend