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_speye.m
    path of file: ./repos/bspm/thirdparty/spm12
    
    the code of the file until where you have to start completion: function [D] = spm_speye(m,n,k)
% sparse leading diagonal matrix
% FORMAT [D] = spm_speye(m,n,k)
%
% returns an m x n matrix with ones along the k-th leading diagonal
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

    
function [D] = spm_speye(m,n,k)
% sparse leading diagonal matrix
% FORMAT [D] = spm_speye(m,n,k)
%
% returns an m x n matrix with ones along the k-th leading diagonal
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Karl Friston
% $Id: spm_speye.m 1131 2008-02-06 11:17:09Z spm $


% default k = 0
%--------------------------------------------------------------------------
if nargin < 3, k = 0; end