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: anom.m
    path of file: ./repos/matlab_owc/matlab_codes
    
    the code of the file until where you have to start completion: 
function fl = anom(d,fl)

% B. King, April 2005.
%
% Brian King's routine for plotting salinity anomaly time series.
% Needs 3 other routines: axmerc.m, setdefault.m, make_colorbar.m.
%
% assume all profiles for a float have been read in from a single netcdf file
% the argument is the structure array created when reading the netcdf file
%
% use:
% fl = anom(d)   or   
%
% fl.useqc = '0';
% fl.plot = 0;   to switch off plotting
% fl.plot = 1; to switch on plotting
% fl.yaxes = [2 5 20]; define the theta levels for plot limits and to divide panels
% fl = anom(d,fl)
%
% The structure d must have the following fields
% d.PLATFORM_NUMBER
% d.PSAL
% d.TEMP
% d.PRES
% d.PSAL_QC
% d.TEMP_QC
% d.PRES_QC
%
% The structure fl is used to pass back some of the working variables as follows:
%
%  fl.theta_base;  theta levels  300x1
%  fl.Smean;  S reference profile 300x1
%  fl.Sanom;  S anomaly array     300xn
%  fl.Sint;   S interpolated array 300xn
%
% the flag fl.useqc is a string variable. The contens of the string are
% the QC flags that are to be retained. eg fl.useqc = '1' retains only data
% with QC flag '1' and sets the rest to NaN. This is the default.
% Use fl.useqc = '0' to keep all data.
%
% note that the arrays contain a large number of zeros
% for depth levels greater than 100. These can be sorted out with
% something like snan = find(S < 1) and T(snan) = nan; P(snan) = nan; S(snan) = nan; etc


theta_base = 0.1:.1:30;
    
function fl = anom(d,fl)

% B. King, April 2005.
%
% Brian King's routine for plotting salinity anomaly time series.
% Needs 3 other routines: axmerc.m, setdefault.m, make_colorbar.m.
%
% assume all profiles for a float have been read in from a single netcdf file
% the argument is the structure array created when reading the netcdf file
%
% use:
% fl = anom(d)   or   
%
% fl.useqc = '0';
% fl.plot = 0;   to switch off plotting
% fl.plot = 1; to switch on plotting
% fl.yaxes = [2 5 20]; define the theta levels for plot limits and to divide panels
% fl = anom(d,fl)
%
% The structure d must have the following fields
% d.PLATFORM_NUMBER
% d.PSAL
% d.TEMP
% d.PRES
% d.PSAL_QC
% d.TEMP_QC
% d.PRES_QC
%
% The structure fl is used to pass back some of the working variables as follows:
%
%  fl.theta_base;  theta levels  300x1
%  fl.Smean;  S reference profile 300x1
%  fl.Sanom;  S anomaly array     300xn
%  fl.Sint;   S interpolated array 300xn
%
% the flag fl.useqc is a string variable. The contens of the string are
% the QC flags that are to be retained. eg fl.useqc = '1' retains only data
% with QC flag '1' and sets the rest to NaN. This is the default.
% Use fl.useqc = '0' to keep all data.
%
% note that the arrays contain a large number of zeros
% for depth levels greater than 100. These can be sorted out with
% something like snan = find(S < 1) and T(snan) = nan; P(snan) = nan; S(snan) = nan; etc


theta_base = 0.1:.1:30;
fl.theta_base = theta_base';
%AW plat = d.PLATFORM_NUMBER;
%AW platchar = plat(1,:);
%AW platchar(findstr(platchar,' '))=[];
clear S T P TH
S = d.PSAL;
T = d.TEMP;
P = d.PRES;
PROFILE_NO=d.PROFILE_NO; %AW
%S = S';
%T = T';
%P = P';
%S(find(S < 30)) = nan;

fl = setdefault(fl,'useqc','1'); %fl.useqc = '1' by default. ie good data only
fl = setdefault(fl,'plot',1);    %fl.plot = 1 by default. ie plotting on.
fl = setdefault(fl,'yaxes',[2 5 20]);

%AW disp(['platform = ' platchar '   useqc = ' num2str(fl.useqc) '   plot = ' num2str(fl.plot)])
%AWdisp(['y range for two panels of plot are: [' num2str(fl.yaxes(1:2)) '] [' num2str(fl.yaxes(2:3)) ']']);

%use qc flags if required; this is default unless fl.useqc passed into function
if strcmp(fl.useqc,'0')
    %retain all data; no qc flag processing
else
    sqc = d.PSAL_QC; sqc = sqc';
    tqc = d.TEMP_QC; tqc = tqc';
    pqc = d.PRES_QC; pqc = pqc';
    for row = 1:size(sqc,1)
        srownan = nan*ones(1,size(sqc,2));
        trownan = srownan;
        prownan = srownan;
        for flag = 1:length(fl.useqc) 
            %for each element of fl.useqc, find the matching flags to keep
            skeep = findstr(sqc(row,:),fl.useqc(flag));
            srownan(skeep) = 0;
            tkeep = findstr(tqc(row,:),fl.useqc(flag));
            trownan(tkeep) = 0;
            pkeep = findstr(pqc(row,:),fl.useqc(flag));
            prownan(pkeep) = 0;
        end