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_generate.m
    path of file: ./repos/bspm/thirdparty/spm12
    
    the code of the file until where you have to start completion: function [DEM] = spm_DEM_generate(M,U,P,h,g)
% Generates data for a Hierarchical Dynamic Model (HDM)
% FORMAT [DEM] = spm_DEM_generate(M,N,P,h,g): N-samples using z
% FORMAT [DEM] = spm_DEM_generate(M,U,P,h,g): size(U,2) samples using U
%
% M(i)     - HDM
% U(n x N} - causes or N number of causes

    
function [DEM] = spm_DEM_generate(M,U,P,h,g)
% Generates data for a Hierarchical Dynamic Model (HDM)
% FORMAT [DEM] = spm_DEM_generate(M,N,P,h,g): N-samples using z
% FORMAT [DEM] = spm_DEM_generate(M,U,P,h,g): size(U,2) samples using U
%
% M(i)     - HDM
% U(n x N} - causes or N number of causes
% P{i}     - model-parameters for level i (defaults to M.pE)
% h{i}     - log-precisions   for level i (defaults to 32 - no noise)
% g{i}     - log-precisions   for level i (defaults to 32 - no noise)
%
% generates
% DEM.M    - hierarchical model (checked)
% DEM.Y    - responses or data
%
% and true causes NB: v{end