function [Sdi] = stat_Sdi(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


%% --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 Sdi
ex = diff(p(:,1));
ey = diff(p(:,2));
i_e = ey./ex;
i_avg = mean(i_e);
Sdi = atand(sqrt(mean((i_e-i_avg).^2)));  
    
