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: setCTFDataBalance.m
    path of file: ./repos/spm12/external/ctf
    
    the code of the file until where you have to start completion: function [data,ds]=setCTFDataBalance(data,ds,balance1,unit,chanList,messages);

%  Version 1.1  13 April 2007  Mod to chanList:  If chanList is omitted and
%                              size(data,2)<ds.res4.no_channels, then setCTFDataBalance
%                              sets chanList=1:size(data,2) and prints a warning the first
%                              time it happens.
%               7 Dec. 2006.   Fixed a bug.  Changed calls to getCTFBalanceCoefs so 
%               setCTFDataBalance would balance and unbalance reference gradiometers.
%  Version 1.0   27 October 2006

%  Adjusts the gradient order balance from balance0 to balance1.
%  Inputs : 
%    data : Array of data to be balanced.  precision= single or double.
%           size(data)=[Npt Nchan Ntrial].  If chanList is not supplied, it is assumed that
%           array data has dataset channels 1:Nc
    
function getDsBalance **********************************
% **********************************************************************************

%  ********************************************************************************
% ******************* function check_balance **************************************
function balance=check_balance(balance);

% make sure that character array balance has the correct format.

balance_options=strvcat('NONE','G1BR','G2BR','G3BR');

% Make balance into a [4 2] character array
if ~ischar(balance) & ~isempty(balance)
  fprintf('setCTFDataBalance (check_balance): balance is not a character array.\n');
  balance=char([]);     % Force an error.
  return;
elseif isempty(deblank(balance))
  balance=strvcat('NONE','NONE');
  return
elseif size(balance,1)==1
  balance=strvcat(balance,'NONE');  % No Gref balancing
elseif size(balance,1)>2
  fprintf('setCTFDataBalance (check_balance): size(balance)=[%d %d]?\n',size(balance));
  balance=char([]);  % Force an error.
  return
end