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: MF_FitSubsegments.m
    path of file: ./repos/hctsa/Operations
    
    the code of the file until where you have to start completion: function out = MF_FitSubsegments(y,model,order,subsetHow,samplep,randomSeed)
% MF_FitSubsegments Robustness of model parameters across different segments of a time series
%
% The spread of parameters obtained (including in-sample goodness of fit
% statistics) provide some indication of stationarity.
%
% Values of goodnes
    
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/>.
% ------------------------------------------------------------------------------

% ------------------------------------------------------------------------------
%% Preliminaries
% ------------------------------------------------------------------------------
N = length(y); % length of time series

% ------------------------------------------------------------------------------
%% Check Inputs
% ------------------------------------------------------------------------------

% (1) y: column vector time series
if nargin < 1 || isempty(y)
    error('Give us a time series, ya mug');
end