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_DEM_F.m
    path of file: ./repos/ExploreASL/External/SPMmodified
    
    the code of the file until where you have to start completion: function [F,p] = spm_DEM_F(DEM,ip)
% Free-energy as a function of conditional parameters
% [F,P1,P2] = spm_DEM_F(DEM))
%
% DEM    - hierarchical model
%
% F(i) - free-energy at <q(P(ip))> = p(i)
%
% where p(i) is the ip-th free-parameter. This is a bound on 
% the log-likehood (log-evidence) conditioned on the expeceted parameters
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
 
% Karl Friston
% $Id: spm_DEM_F.m 4146 2010-12-23 21:01:39Z karl $
 
 
% Find paramter ranges (using prior covariance)
%--------------------------------------------------------------------------
pE   = spm_vec(DEM.M(1).pE);
p    = linspace(-6,6,16);
dp   = sqrt(DEM.M(1).pC(ip,ip))*p;
p    = dp + pE(ip);
 
% get F
%==========================================================================
DEM.M(1).E.nE = 1;
DEM.M(1).E.nN = 1;

for i = 1:length(p)
    
    % adjust paramter (through prio expecatation)
    %----------------------------------------------------------------------
    P          = pE;
    P(ip)      = p(i);
    DEM.M(1).P = spm_unvec(P,DEM.M(1).pE);
    

    
function [F,p] = spm_DEM_F(DEM,ip)
% Free-energy as a function of conditional parameters
% [F,P1,P2] = spm_DEM_F(DEM))
%
% DEM    - hierarchical model
%
% F(i) - free-energy at <q(P(ip))> = p(i)
%
% where p(i) is the ip-th free-parameter. This is a bound on 
% the log-likehood (log-evidence) conditioned on the expeceted parameters
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
 
% Karl Friston
% $Id: spm_DEM_F.m 4146 2010-12-23 21:01:39Z karl $
 
 
% Find paramter ranges (using prior covariance)
%--------------------------------------------------------------------------
pE   = spm_vec(DEM.M(1).pE);
p    = linspace(-6,6,16);
dp   = sqrt(DEM.M(1).pC(ip,ip))*p;
p    = dp + pE(ip);
 
% get F
%==========================================================================
DEM.M(1).E.nE = 1;
DEM.M(1).E.nN = 1;

for i = 1:length(p)
    
    % adjust paramter (through prio expecatation)
    %----------------------------------------------------------------------
    P          = pE;
    P(ip)      = p(i);
    DEM.M(1).P = spm_unvec(P,DEM.M(1).pE);
    
    % comute free-energy
    %----------------------------------------------------------------------
    DEM  = spm_DEM(DEM);
    F(i) = DEM.F(end