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: projectOntoBMCIII.m
    path of file: ./repos/chebfun/@ballfun
    
    the code of the file until where you have to start completion: function f = projectOntoBMCIII( f )
% PROJECTONTOBMCI  Projection onto BMC-III symmetry.
%
% f = projectOntoBMCIII(f) is the orthogonal projection of f onto BMC-III
% symmetry, i.e., a function that is
% 1. even in theta for every even wave numb
    
function X = projectOntoRTheta( X )
% Project the matrix of Chebyshev--Fourier coefficients onto a BMC-II
% function. The projection is orthogonal, i.e., the correction matrix to
% fix up the structure has the smallest possible Frobenius norm. 

% Get the discretization
[m,n] = size(X);

zeroMode = floor(n/2)+1;
evenModes = [fliplr(zeroMode-2:-2:1) zeroMode+2:2:n];  % Not including the zero mode
oddModes = [fliplr(zeroMode-1:-2:1) zeroMode+1:2:n];

% First do the zero-periodic mode in theta. 
% Enforce the expansion is even in r.
I = eye( m ); A = I(2:2:end