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: fiff_write_float_sparse_rcs.m
    path of file: ./repos/spm/external/mne
    
    the code of the file until where you have to start completion: function fiff_write_float_sparse_rcs(fid,kind,mat)
%
% fiff_write_float_sparsce_rcs(fid,kind,mat)
% 
% Writes a single-precision sparse (RCS) floating-point matrix tag
%
%     fid           An open fif file descriptor
%     kind          The tag kind
%     mat           The data matrix
%

%
%   Author : Matti Hamalainen, MGH Martinos Center
%   License : BSD 3-clause
%

me='MNE:fiff_write_float_sparse_rcs';

if nargin ~= 3

    
function fiff_write_float_sparse_rcs(fid,kind,mat)
%
% fiff_write_float_sparsce_rcs(fid,kind,mat)
% 
% Writes a single-precision sparse (RCS) floating-point matrix tag
%
%     fid           An open fif file descriptor
%     kind          The tag kind
%     mat           The data matrix
%

%
%   Author : Matti Hamalainen, MGH Martinos Center
%   License : BSD 3-clause
%

me='MNE:fiff_write_float_sparse_rcs';

if nargin ~= 3
   error(me,'Incorrect number of arguments');
end

if ~issparse(mat)
   error(me,'Input should be a sparse matrix');
end

if length(size(mat)) ~= 2
   error(me,'Input should be a two-dimensional matrix');
end

FIFFT_FLOAT  = 4;
FIFFT_MATRIX = bitshift(16416,16);    % 4020
FIFFT_MATRIX_FLOAT_RCS = bitor(FIFFT_FLOAT,FIFFT_MATRIX);
FIFFV_NEXT_SEQ=0;
%
%    nnz values
%    nnz column indices
%    nrow+1 pointers
%    dims
%    nnz
%    ndim
%
nnzm = nnz(mat);
nrow = size(mat,1);
datasize = 4*nnzm + 4*nnzm + 4*(nrow+1) + 4*4;
%
%    Nonzero entries
%
[ s(:,1), s(:,2), s(:,3) ] = find(mat);
s = sortrows(s,1);
[ rows, starts ] = unique(s(:,1),'first');

count = fwrite(fid,int32(kind),'int32');
if count ~= 1
   error(me,'write failed');
end