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: read_besa_besa.m
    path of file: ./repos/spm/external/fieldtrip/fileio/private
    
    the code of the file until where you have to start completion: function [data] = read_besa_besa(filename, header, begsample, endsample, chanindx)

% READ_BESA_BESA reads data and header information from a BESA file
% See formatting document <a href="matlab:web(http://www.besa.de/downloads/file-formats/)">here</a>
% 
% Use as
%   [header] = read_besa_besa(filename);
% where
%    filename        name of the datafile, including the .besa extension
% This returns a header structure with the following elements
%   header.Fs           sampling frequency
%   header.nChans       number of channels
%   header.nSamples     number of samples per trial
%   header.nSamplesPre  number of pre-trigger samples in each trial
%   header.nTrials      number of trials
%   header.label        cell-array with labels of each channel
%   header.orig         detailed BESA header information
%
% Use as
%   [header] = read_besa_besa(filename, [], chanindx);
% where
%    filename        name of the datafile, including the .besa extension
%    chanindx        index of channels to read (optional, default is all)
% This returns a head
    
function output = thirdscheme_lookup(input, meshgrid_vals)
% Lookup table for third scheme

% Use persistent variable so lookup table does not need to be recomputed each time
persistent thirdscheme_lookuptable;
if isempty(thirdscheme_lookuptable)
  
  % Create the lookup grid from -1 to 1 in x, y, z, c
  [thirdscheme_lookuptable_a(:,:,:,:,1),thirdscheme_lookuptable_a(:,:,:,:,2),thirdscheme_lookuptable_a(:,:,:,:,3),thirdscheme_lookuptable_a(:,:,:,:,4)] = ...
    ndgrid(meshgrid_vals.A);
  % Reshape the lookup grid to be [1:81 x 1:4]
  thirdscheme_lookuptable_a = reshape(thirdscheme_lookuptable_a,[numel(meshgrid_vals.A)^4 4]);
  % Correct order of x,y,z,c
  thirdscheme_lookuptable_a(:,[1 2 3 4]) = thirdscheme_lookuptable_a(:,[4 3 2 1]);
  
  % Create the lookup grid from -6 to 6 in x and y
  [thirdscheme_lookuptable_b(:,:,1),thirdscheme_lookuptable_b(:,:,2)] = meshgrid(meshgrid_vals.B,meshgrid_vals.B);
  % Reshape the lookup grid to be [1:169 x 1:2]
  thirdscheme_lookuptable_b = reshape(thirdscheme_lookuptable_b,[numel(meshgrid_vals.B)^2 2]);
  
  % Put the lookup tables together in a cell-array (because of different sized cells)
  thirdscheme_lookuptable = num2cell(thirdscheme_lookuptable_a,2);
  thirdscheme_lookuptable = [thirdscheme_lookuptable; num2cell(thirdscheme_lookuptable_b,2)];
  
  clear thirdscheme_lookuptable_a;
  clear thirdscheme_lookuptable_b;
end