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: indsample.m
    path of file: ./repos/bspm/thirdparty/spm12/@meeg
    
    the code of the file until where you have to start completion: function res = indsample(this, t)
% Method for getting the sample closest to some time point
% FORMAT res = indsample(this, t)
% this       - MEEG object
% t          - vector of time points in seconds
%
% res        - vector of sample indices matching time points
%__________________________________________________________________________

    
function res = indsample(this, t)
% Method for getting the sample closest to some time point
% FORMAT res = indsample(this, t)
% this       - MEEG object
% t          - vector of time points in seconds
%
% res        - vector of sample indices matching time points
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Stefan Kiebel
% $Id: indsample.m 3742 2010-03-02 15:15:43Z vladimir $

res = NaN(1,length(t));
if this.Nsamples > 0
    T = time(this);
    for i = 1:length(t)
        if isfinite(t(i))
            [m,res(i)] = min(abs(T-t(i)));
            if m > (1/this.Fsample)
                warning('Could not find an index matching the requested time %d sec', t(i));
                res(i) = NaN;
            end