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_ADEM_update.m
    path of file: ./repos/spm12
    
    the code of the file until where you have to start completion: function [DEM] = spm_ADEM_update(DEM,COV)
% Updates ADEM structure using conditional expectations
% FORMAT [DEM] = spm_ADEM_update(DEM,COV)
%
% DEM - DEM structure
% COV - Covariance of parameter (P) fluctuations (E): P(i + 1) = P(i) + E
%     - where cov(E) = COV*pC
%
% This routine updates posterior expectations about states and parameters
% by replacing prior expectations with posterior expectations (and
% similarly updating hidden states and causes to the final iteration). If
% called with an extra argument, the posterior variances of the

    
function [DEM] = spm_ADEM_update(DEM,COV)
% Updates ADEM structure using conditional expectations
% FORMAT [DEM] = spm_ADEM_update(DEM,COV)
%
% DEM - DEM structure
% COV - Covariance of parameter (P) fluctuations (E): P(i + 1) = P(i) + E
%     - where cov(E) = COV*pC
%
% This routine updates posterior expectations about states and parameters
% by replacing prior expectations with posterior expectations (and
% similarly updating hidden states and causes to the final iteration). If
% called with an extra argument, the posterior variances of the
% parameters are also updated.
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Karl Friston
% $Id: spm_ADEM_update.m 6506 2015-07-24 10:26:51Z karl $


% preliminaries
%--------------------------------------------------------------------------
if nargin < 2, COV = 0; end