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: MarkovChainSimulation.m
    path of file: ./repos/VFIToolkit-matlab/Other
    
    the code of the file until where you have to start completion: function z_timeseries=MarkovChainSimulation(T,z_grid,pi_z,simoptions,n_z)
% Create a time-series simulation of a (one dimensional) first-order discrete markov process.
% (can do higher dimensional using optional input n_z)
% Inputs:
%  T        - number of time periods to simulate
%  z_grid   - grid values of the discrete markov process (column vector)
%  pi_z     - transition matrix of the discrete markov process (matrix, row gives probabilities for next period states, should add to one)
% Optional inputs
%  simoptions.burnin    - number of periods to 'burn in' (these are automatically  deleted from simulation to eliminate bias caused by initial seed point value)

    
function z_timeseries=MarkovChainSimulation(T,z_grid,pi_z,simoptions,n_z)
% Create a time-series simulation of a (one dimensional) first-order discrete markov process.
% (can do higher dimensional using optional input n_z)
% Inputs:
%  T        - number of time periods to simulate
%  z_grid   - grid values of the discrete markov process (column vector)
%  pi_z     - transition matrix of the discrete markov process (matrix, row gives probabilities for next period states, should add to one)
% Optional inputs
%  simoptions.burnin    - number of periods to 'burn in' (these are automatically  deleted from simulation to eliminate bias caused by initial seed point value)
%  simoptions.seedpoint - point from which to start the simulation
%  simoptions.nsims     - number of simulations (by default it is 1, so you just get a time series)
%  n_z      - if z has more than one dimension you need to input the number of discrete points per dimension

%% Set default options
if ~exist('n_z') % Assume z is one-dimensional
    n_z=length(z_grid);
end