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_MDP_plot.m
    path of file: ./repos/spm12/toolbox/DEM
    
    the code of the file until where you have to start completion: function spm_MDP_plot(MDP)
% creates a movie of hierarchical expectations and outcomes
% FORMAT spm_MDP_plot(MDP))
%
% MDP - nested MDP (and DEM) structures
%     - (requires fields to specify the labels of states and outcomes)

    
function spm_MDP_plot(MDP)
% creates a movie of hierarchical expectations and outcomes
% FORMAT spm_MDP_plot(MDP))
%
% MDP - nested MDP (and DEM) structures
%     - (requires fields to specify the labels of states and outcomes)
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Karl Friston
% $Id: spm_MDP_plot.m 6977 2016-12-24 17:48:44Z karl $

% Preliminaries
%--------------------------------------------------------------------------
cla,axis([1 20 0 8]); axis image, hold on, box on
set(gca,'Fontsize',16,'XColor','r','TickLength',[0 0],'XTick',[],'YTick',[])
title('Narrative construction','FontSize',16)

% switch off basis functions for visual stimuli
%--------------------------------------------------------------------------
try
global STIM
B = STIM.B;
STIM.B = 1;
end

% hidden factors to display (one per level)
%--------------------------------------------------------------------------
scale  = 1 - 1/16;                             % background level for text
try k1 = MDP.label.k;     catch, k1 = 1; end
try k2 = MDP.MDP.label.k; catch, k2 = 1; end

% cycle over highest level
%--------------------------------------------------------------------------
T1     = size(MDP.xn{k1},4);
F1     = fix(1024/(T1*numel(MDP.label.name{k1}{1})));
F1     = min(max(F1,8),32);
for t1 = 1:T1
    
    % draw stuff
    %----------------------------------------------------------------------
    p     = 1 - squeeze(MDP.xn{k1}(end