function [Rp,delta] = stat_Rp_delta(p)

%% License:
% "This work is licensed under the Creative Commons Attribution 4.0
% International (CC BY 4.0) License. To view a copy of this license, visit:
% http://creativecommons.org/licenses/by/4.0/"

%% please cite 
% --> Kristofer Marsch (2020)
% --> DOI for this data available at https://orcid.org/0000-0002-1857-506X


%% calculating Rp and delta
% Rp: Roughness Profile index
% delta: Profile elongation index

%% --parameters-- %%
% p: array of profile, first column horizontal values, second column heights
% profile must be de-trended
% profile must have equal point distances, e.g. constant sampling interval

%% calculate Rp and delta
ex = diff(p(:,1));
ey = diff(p(:,2));
Le = sqrt(ex.^2+ey.^2);
L = p(end,1)-p(1,1);
Rp = sum(Le)/L;
delta = (sum(Le)-L)/L;

