for line = 22%1:22
    year = 2009;
    month = 7:12;
    for i = 1: length(month)
        [cross_shore,altitude(:,i)] = combine_surveys(year,month(i),line);
    end
    year = 2010;
    month = 1:5;
    for i = 1: length(month)
        [cross_shore,altitude(:,i+6)] = combine_surveys(year,month(i),line);
    end
    pro_var(:,line) =  nanvar(altitude')';
    pro_mean(:,line) = nanmean(altitude')';
    index_runup(1,line) = find(cross_shore > 50 & cross_shore < 150 & pro_var(:,line) > 0.01 ,1,'first');

    cross_runup_lim(:,line) = cross_shore(index_runup(1,line));
    Z_runup_lim(:,line) = pro_mean(index_runup(1,line),line);

end

figure
subplot(2,1,1)
plot(cross_shore,altitude, 'DisplayName', 'altitude', 'YDataSource', 'altitude'); figure(gcf)
hold all
% plot(cross_shore,pro_mean(:,line),'k','linewidth',2);
title(['Elevation along line ' num2str(line) ' showing 11 months'])
xlabel('Cross Shore [m]')
ylabel('Elevation wrt NAP [m]')
    set(gca,'XDir','reverse')
xlim([-300 1200])
hline(0)
%     hline(3,':g')

subplot(2,1,2)
plot(cross_shore, pro_var(:,line),'linewidth',2);
title(['Measured variance along profile nr. ' num2str(line)])
xlabel('Cross Shore [m]')
ylabel('Variance [m^2]')
    set(gca,'XDir','reverse')
xlim([-300 1200])

figure;
plot(cross_shore,altitude(:,2),...
    'DisplayName', datestr(datenum(num2str([month(i) year]),'mm yyyy'),'mmmm yy'),...
    'linewidth',2);
    legend show
    title(['Elevation along line ' num2str(line)])
    xlabel('Cross Shore [m]')
    ylabel('Elevation wrt NAP [m]')
    xlim([-300 1500])
    hline(0)
    hline(3,':g')
        set(gca,'XDir','reverse')




