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: SC_FluctAnal.m
    path of file: ./repos/hctsa/Operations
    
    the code of the file until where you have to start completion: function out = SC_FluctAnal(x,q,wtf,tauStep,k,lag,logInc)
% SC_FluctAnal   Implements fluctuation analysis by a variety of methods.
%
% Much of our implementation is based on the well-explained discussion of
% scaling methods in:
% "Power spectrum and detrended fluctuation analysis: Application to daily
% temperatures" P. Talkner and R. O. Weber, Phys. Rev. E 62(1) 150 (2000)
%
% The main difference between algorithms for estimating scaling exponents amount
% to differences in how fluctuations, F, are quantified in time-series segments.
% Many alternatives are implemented in this function.
%
%---INPUTS:
% x, the input time series
%
% q, the parameter in the fluctuation function q = 2 (usual) gives RMS fluctuations.
%
% wtf, (what to fluctuate)
%       (i) 'endptdiff', calculates the differences in end points in each segment
%       (ii) 'range' calculates the range in each segment
%       (iii) 'std' takes the standard deviation in each segment
%           cf. "Evaluating scaled windowed variance methods for estimating the
%               Hurst coefficient of time series", M. J. Cannon et al. Physica A
%               241(3-4) 606 (1997)
%       (iv) 'iqr' takes the interquartile range in each segment
%       (v) 'dfa' removes a polynomial trend of order k in each segment,
%       (vi) 'rsrange' returns the range after removing a straight line fit
%           cf. "Analyzing exact fractal time series: evaluating dispersional
%           analysis and rescaled range methods",  D. C. Caccia et al., Physica
%           A 246(3-4) 609 (1997)
%       (vii) 'rsrangefit' fits a polynomial of order k and then returns the
%           range. The parameter q controls the order of fluctuations, for which
%           we mostly use the standard choice, q = 2, corresponding to root mean
%           square fluctuations.
%           An optional input parameter to this operation is a timelag for
%           computing the cumulative sum (or integrated profile), as suggested
%           by: "Using detrended fluctuation analysis for lagged correlation
%           analysis of nonstationary signals" J. Alvarez-Ramirez et al. Phys.
%           Rev. E 79(5) 057202 (2009)
%
% tauStep, number of tau (locInc true), or increments in tau for linear range
%               (if logInc = 0), or
%
%           The spacing of timescales, tau, is commonly logarithmic through a range from
%           5 samples to a quarter of the length of the time series, as suggested in
%           "Statistical properties of DNA sequences", C.-K. Peng et al. Physica A
%           221(1-3) 180 (1995)
%
%           Max A. Little's fractal paper used L = 4 to L = N/2:
%           "Exploiting Nonlinear Recurrence and Fractal Scaling Properties for
%           Voice Disorder Detection", Little et al. Biomed. Eng. Online 6 23 (2007)
%
% k, polynomial order of detrending (for 'dfa' & 'rsrangefit')
%
% lag, optional time-lag, as in Alvarez-Ramirez (see (vii) above)
%
% logInc, whether to use logarithmic
    
function to a plot of log(F) as
% a function of log(tau), and for fitting two straight lines to the same data,
% choosing the split point at tau = tau_{split} as that which minimizes the
% combined fitting errors.
%
% This function can also be applied to the absolute deviations of the time
% series from its mean, and also for just the sign of deviations from the mean
% (i.e., converting the time series into a series of +1, when the time series is
% above its mean, and -1 when the time series is below its mean).
%
% All results are obtained with both linearly, and logarithmically-spaced time
% scales tau.

% ------------------------------------------------------------------------------
% Copyright (C) 2020, Ben D. Fulcher <ben.d.fulcher@gmail.com>,
% <http://www.benfulcher.com>
%
% If you use this code for your research, please cite the following two papers:
%
% (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated
% Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017).
% DOI: 10.1016/j.cels.2017.10.001
%
% (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series
% analysis: the empirical structure of time series and their methods",
% J. Roy. Soc. Interface 10(83) 20130048 (2013).
% DOI: 10.1098/rsif.2013.0048
%
% This function is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option) any later
% version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public License along with
% this program. If not, see <http://www.gnu.org/licenses/>.
% ------------------------------------------------------------------------------

% ------------------------------------------------------------------------------
% Check Inputs:
% ------------------------------------------------------------------------------
if nargin < 2 || isempty(q)
    q = 2; % RMS fluctuations
end
if nargin < 3 || isempty(wtf)
    wtf = 'rsrange'; % re-scaled range analysis by default
end
if nargin < 4 || isempty(tauStep)
    % the increment of tau (for linear)
    % or number of points in logarithmic range (for logarithmic)
    tauStep = 1;
end
if nargin < 5 || isempty(k)
    k = 1; % often not needed, only for 'dfa' and 'rsrangefit'
end
if nargin < 6
    lag = '';
end
if nargin < 7
	logInc = true;
end

% ------------------------------------------------------------------------------
N = length(x); % length of the time series
doPlot = false; % plot relevant outputs to figure

%-------------------------------------------------------------------------------
% 1) Compute integrated sequence
if isempty(lag) || lag==1
    % A normal cumsum:
    y = cumsum(x);
else
    % If a lag is specified, do a decimation:
    y = cumsum(x(1:lag:end