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_dcm_erp_viewspatial.m
    path of file: ./repos/malini/Codes/deconvolution - model/spm8/toolbox/dcm_meeg
    
    the code of the file until where you have to start completion: function varargout = spm_dcm_erp_viewspatial(varargin)
% SPM_DCM_ERP_VIEWSPATIAL M-file for spm_dcm_erp_viewspatial.fig
%      SPM_DCM_ERP_VIEWSPATIAL, by itself, creates a new SPM_DCM_ERP_VIEWSPATIAL or raises the existing
%      singleton*.
%
%      H = SPM_DCM_ERP_VIEWSPATIAL returns the handle to a new SPM_DCM_ERP_VIEWSPATIAL or the handle to
%      the existing singleton*.
%
%      SPM_DCM_ERP_VIEWSPATIAL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SPM_DCM_ERP_VIEWSPATIAL.M with the given input arguments.
%
%      SPM_DCM_ERP_VIEWSPATIAL('Property','Value',...) creates a new SPM_DCM_ERP_VIEWSPATIAL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before spm_dcm_erp_viewspatial
    
function plot_components_space(hObject, handles)
% plots spatial expression of each dipole
DCM = handles.DCM;
Nsources = length(DCM.M.pE.A{1});

lf  = NaN*ones(handles.Nchannels, Nsources);
lfo = NaN*ones(handles.Nchannels, Nsources);
x   = [0 kron([zeros(1, 8) 1], ones(1, Nsources))];

% unprojected and projected leadfield
%--------------------------------------------------------------------
lfo(DCM.M.dipfit.Ic,:) = spm_erp_L(DCM.Eg,DCM.M);
lf                     = DCM.M.E*DCM.M.E'*lfo;


% use subplots in new figure
h = figure;
set(h, 'Name', 'Spatial expression of sources');
for j = 1:2
    for i = 1:Nsources
        if j == 1
            % projected
            handles.hcomponents{i} = subplot(2,Nsources, i);
            z = griddata(handles.xp, handles.yp, lf(:, i), handles.x1, handles.y1);
            title(DCM.Sname{i}, 'FontSize', 16);
        
        else
            % not projected
            handles.hcomponents{i} = subplot(2,Nsources, i+Nsources);
            z = griddata(handles.xp, handles.yp, lfo(:, i), handles.x1, handles.y1);
        end