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: of_MARE.m
    path of file: ./repos/MARRMoT/MARRMoT/Functions/Objective functions
    
    the code of the file until where you have to start completion: function [val,idx] = of_MARE(obs,sim,idx)
% of_MARE Calculates the Mean Absolute Relative Error of simulated 
% streamflow. Ignores time steps with negative flow values.  Adds a constant
% e of 1/100 of mean(obs) to avoid issues with zero flows (Pushpalatha et

    
function [val,idx] = of_MARE(obs,sim,idx)
% of_MARE Calculates the Mean Absolute Relative Error of simulated 
% streamflow. Ignores time steps with negative flow values.  Adds a constant
% e of 1/100 of mean(obs) to avoid issues with zero flows (Pushpalatha et
% al., 2012).

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% In:
% obs       - time series of observations       [nx1]
% sim       - time series of simulations        [nx1]
% idx       - optional vector of indices to use for calculation, can be
%               logical vector [nx1] or numeric vector [mx1], with m <= n
%
% Out:
% val       - objective function value          [1x1]
% idx       - vector of indices used for calculation

% Pushpalatha, R.; Perrin, C.; le Moine, N. and AndrÃ©assian V. (2012). "A
% review of efficiency criteria suitable for evaluating low-flow
% simulations". Journal of Hydrology. 420-421, 171-182. 
% doi:10.1016/j.jhydrol.2011.11.055

%% Check inputs and select timesteps
if nargin < 2
    error('Not enugh input arguments')    
end