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_cells.m
    path of file: ./repos/spm12/toolbox/DEM
    
    the code of the file until where you have to start completion: function DEM = DEM_cells

% This demo illustrates self-organisation in an ensemble of (sixteen) cells
% using the same principles described in DEM_morphogenesis, but using a
% simpler generative model. Overall, the dynamics of these simulations show
% how one can prescribe a point attractor for each constituent of an
% ensemble that endows the ensemble with a point attractor to which it
% converges. In this example, we consider the special case where the point
% attractor is itself a Markov blanket. In other words, cells come to
% acquire dependencies, in terms of intracellular signalling, that conform
% to a simple Markov blanket with intrinsic or internal cells, surrounded
% by active cells that are, in turn, surrounded by sensory cells. This
% organisation rests upon intracellular signals and active inference using
% generalised (second-order) variational filtering. In brief, the hidden

    
function DEM = DEM_cells

% This demo illustrates self-organisation in an ensemble of (sixteen) cells
% using the same principles described in DEM_morphogenesis, but using a
% simpler generative model. Overall, the dynamics of these simulations show
% how one can prescribe a point attractor for each constituent of an
% ensemble that endows the ensemble with a point attractor to which it
% converges. In this example, we consider the special case where the point
% attractor is itself a Markov blanket. In other words, cells come to
% acquire dependencies, in terms of intracellular signalling, that conform
% to a simple Markov blanket with intrinsic or internal cells, surrounded
% by active cells that are, in turn, surrounded by sensory cells. This
% organisation rests upon intracellular signals and active inference using
% generalised (second-order) variational filtering. In brief, the hidden
% causes driving action (migration and signalling) are expectations about
% cell type. These expectations are optimised using sensory signals;
% namely, the signals generated by other cells. By equipping each cell with
% prior beliefs about what it would sense if it was a particular cell type
% (i.e., internal, active or sensory), they act (i.e., move and signal) to
% behave and infer their role in an ensemble of cells that itself has a
% Markov blanket. In a DEM_cells_cells.m, we use this first-order scheme to
% simulate the hierarchical emergence of Markov blankets; i.e., ensembles
% of cells that can be one of three types at the local level; independently
% of their time at the global level.
%__________________________________________________________________________
% Copyright (C) 2017 Wellcome Trust Centre for Neuroimaging
 
% Karl Friston
% $Id: DEM_cells.m 7447 2018-10-13 15:32:10Z karl $

% preliminaries
%--------------------------------------------------------------------------
clear global
rng('default')
N         = 32;                              % duration of process

% generative process and model
%==========================================================================
M(1).E.d  = 1;                               % approximation order
M(1).E.n  = 2;                               % embedding order
M(1).E.s  = 1;                               % smoothness
M(1).E.dt = 2;                               % time step

% Target morphology
%==========================================================================
n     = [1 6 9];                             % internal, active and sensory
r     = [0 1 3];                             % radial distance from centre
pos   = [];                                  % position
typ   = [];                                  % cell type
for j = 1:length(n)
    for i = 1:n(j)
        pos(:,end