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: SOFAsave.m
    path of file: ./repos/SOFAtoolbox/SOFAtoolbox
    
    the code of the file until where you have to start completion: function [Obj] = SOFAsave(filename,Obj,varargin)
%SOFAsave - Save a SOFA object to a SOFA file
%   Usage: Obj = SOFAsave(fn,Obj)
%          Obj = SOFAsave(fn,Obj,compression)
%
%   SOFAsave(fn, Obj) creates a new SOFA file with the name fn and stores 
%   the SOFA object Obj in that file. Before storing, the existence of 
%   mandatory variables in Obj is checked and the dimensions are updated. 
%   Further, DateModified is set to now, DateCreated is created if 
%   not provided in Obj, and all read-only metadata is reset to its standard
%   values. The convention's version is not updated while saving. A matching
%   csv file with convention+version must be existing in the conventions 
%   folder, otherwise an error is thrown.
%
%   SOFAsave(fn,Obj,compression) specifies the amount of compression of the 
%   file as a number between 0 and 9. compression of 0 is no compression and 
%   9 is the largest compression available. For the compression, ZIP algorithm
%   is used.
%   

    
function [Obj] = SOFAsave(filename,Obj,varargin)
%SOFAsave - Save a SOFA object to a SOFA file
%   Usage: Obj = SOFAsave(fn,Obj)
%          Obj = SOFAsave(fn,Obj,compression)
%
%   SOFAsave(fn, Obj) creates a new SOFA file with the name fn and stores 
%   the SOFA object Obj in that file. Before storing, the existence of 
%   mandatory variables in Obj is checked and the dimensions are updated. 
%   Further, DateModified is set to now, DateCreated is created if 
%   not provided in Obj, and all read-only metadata is reset to its standard
%   values. The convention's version is not updated while saving. A matching
%   csv file with convention+version must be existing in the conventions 
%   folder, otherwise an error is thrown.
%
%   SOFAsave(fn,Obj,compression) specifies the amount of compression of the 
%   file as a number between 0 and 9. compression of 0 is no compression and 
%   9 is the largest compression available. For the compression, ZIP algorithm
%   is used.
%   
%   SOFAsave will output a warning if GLOBAL_API and GLOBAL_APIName does not match 
%   the actual API name and version, respectively. To supress these warnings, use
%
%      warning('off','SOFA:save:API');
%
%   before calling SOFAsave(..). 
%   
%   Obj=SOFAsave(..) returns the updated object.
%
 

% #Author: Piotr Majdak
% #Author: Michael Mihocic: doc and header documentation updated (28.10.2021)
%
% SOFA Toolbox - function SOFAsave
% Copyright (C) Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: https://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing  permissions and limitations under the License. 

Def = SOFAdefinitions;

%% check file name
filename=SOFAcheckFilename(filename);

%% Remove private data
if isfield(Obj,'PRIVATE'), Obj=rmfield(Obj,'PRIVATE'); end