clear all,close all,clc
addpath D:\pruis\XBeach\MatlabScripts\benodigd

eq=load('z_run_00.dep') %dit is het begin
equi=eq(2,:)
eq2=load('z_run_01.dep') %dit is het begin van de 2e orkaan
equi2=eq2(2,:)
eq3=load('z_run_02.dep') %dit is het begin van de 3e orkaan
equi3=eq3(2,:)
eq4=load('z_run_03.dep') %dit is het begin van de 4e orkaan
equi4=eq4(2,:)
B(1,:)=load('profile_B_01.txt')
B(2,:)=load('profile_B_02.txt')
B(3,:)=load('profile_B_03.txt')
B(4,:)=load('profile_B_04.txt')
A(1,:)=load('profile_A_01.txt')
A(2,:)=load('profile_A_02.txt')
A(3,:)=load('profile_A_03.txt')
A(4,:)=load('profile_A_04.txt')

for j=1:1
    j=2
%     pre_storm_all=load(['z_run_',num2str(i,'%02i'),'.dep'])
%     pre_storm=pre_storm_all(2,:)
% 
%     A=load(['profile_A_',num2str(i,'%02i'),'.txt'])
%     B=load(['profile_B_',num2str(i,'%02i'),'.txt'])
     
%     figure()
    plot(xas,A(j,:),'r'), hold on,
    plot(xas,allequilibriumprofiles(j,:),'b')
    plot(xas,B(j,:),'m')
%     plot(xas,pre_storm,'k')
    legend('A','equilibrium','B')
    pause(0.5)
end

A(2,:)B(2,:)
[IntersectA IntersectB intersections]=CalcintersectionsArea(A(2,:),B(2,:),MSLevel,wavebase,xas);
%calculate overwash volume
%first intersection behind the x-value which belongs to the max elevation
[x y]=max(A(2,:));
xfind=xas(y);
[x y]=find((intersections.A.B(1,:)>=xfind),1);
x1=intersections.A.B(1,y);
x1=0
x2=xas(end);
[Volume]=calcVolume(IntersectA, IntersectB,x1,x2);

[equilibriumprofile stormprofile]=CreateEquilibriumProfile(i,Volumetranslation,initialprofile,A(2,:),B(2,:),intersections,wavebase,MSLevel,xas);
i=2

AA=load('profile_A_02.txt')
hold on, plot(xas,AA,':b')

plot(xas,equi,':k'),hold on,
plot(xas,A,'r')
plot(xas,B,'g')
plot(xas,equi2,':g')
plot(xas,equi3,':m')
plot(xas,equi4,':r')