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: DEM_demo_dendrite.m
    path of file: ./repos/spm/toolbox/DEM
    
    the code of the file until where you have to start completion: function DEM_demo_dendrite
% Free-energy and the single neuron:
%__________________________________________________________________________
% This demo illustrates the use of Lotka-Volterra form SHCs (Stable
% heteroclinic channels) to prescribe active sampling (inference). In this
% example, we assume that neurons self-organise to minimise a free energy
% bound on the informational surprise in the pre-synaptic inputs that are 
% sampled.  We model this as a selective pruning of post-synaptic spines 
% that are expressed on the dendritic tree.  This pruning occurs when the 
% (optimised) post-synaptic gain falls to small values.  Crucially, post-
% synaptic gain (encoding the precision of the neuron's prediction errors 
% about its pre-synaptic inputs) is itself optimised with respect to free-
% energy.  Furthermore, the pruning itself suppresses free-energy as the 

    
function DEM_demo_dendrite
% Free-energy and the single neuron:
%__________________________________________________________________________
% This demo illustrates the use of Lotka-Volterra form SHCs (Stable
% heteroclinic channels) to prescribe active sampling (inference). In this
% example, we assume that neurons self-organise to minimise a free energy
% bound on the informational surprise in the pre-synaptic inputs that are 
% sampled.  We model this as a selective pruning of post-synaptic spines 
% that are expressed on the dendritic tree.  This pruning occurs when the 
% (optimised) post-synaptic gain falls to small values.  Crucially, post-
% synaptic gain (encoding the precision of the neuron's prediction errors 
% about its pre-synaptic inputs) is itself optimised with respect to free-
% energy.  Furthermore, the pruning itself suppresses free-energy as the 
% neuron selects post-synaptic specialisations that conform to its 
% expectations.  This provide a principled account of how neurons organise 
% and selectively sample the myriad of potential pre-synaptic inputs they 
% are exposed to, but it also connects elemental neuronal (dendritic) 
% processing to generic schemes in statistics and machine learning:
% such as Bayesian model selection and automatic relevance determination. 
% The demonstration of this scheme simulates direction selectivity in post
% synaptic transients and (see notes after 'return') spike-timing dependent
% plasticity.
%__________________________________________________________________________
 
% Karl Friston
% Copyright (C) 2008-2022 Wellcome Centre for Human Neuroimaging
 
% preliminaries
%==========================================================================
rng('default')
DemoMode = 0;
 
% generative model - Stable heteroclinic channel of pre-synaptic neurons
%==========================================================================
fx  = inline('spm_lotka_volterra(x,exp(v))','x','v','P');
gx  = inline('x(P.w)','x','v','P');
 
% connection weights: NB synapses are changed by switching Y (not P.w)
%--------------------------------------------------------------------------
np  = 5;                              % number of pre-synaptic neurons
ns  = 4;                              % number of dend