%% make plots of the  profiles for each survey
Mpath='F:\check_outs\tudelft\vlugtenburg'

% figures save in folders per survey, and per profile

savefigs=1; %Toggle  to save the images

% load data
load([Mpath '\AllVbeachsurveys.mat'])

for i_transect=1:22;
%i_transect=2;
for i_date=1:length(Vsurvey)
timestack(i_date,:)=Vsurvey(i_date).transects.elevation(:,i_transect)';
x=Vsurvey(i_date).transects.cr_sh(:)    ;
date(i_date)=Vsurvey(i_date).matlabdate;
end

 %% Timestack profile
for i_date=1:length(Vsurvey);
figure(12)
 set(gcf,'PaperPosition',[0  0  40 20])
 set(gcf,'Position',[100          131        1680/2         944/2])
plot(x,nanmean(timestack(1:4,:)))
grid on

hold all
plot(x,timestack(i_date,:),'k')

hold all
legend('Profile Summer 2009',['Profile ' datestr(date(i_date))])
title([ 'Profile ' num2str(i_transect)])
set (gca,'Ytick',[-10:5])
ylim([-10 5])
xlim([0 1200])
hold off

if savefigs==1
dirname=['PerSurvey\' datestr(date(i_date),'YYYYmmdd') '\'];
filename=[ 'Profilesincecompletion' num2str(i_transect,'%02.0f') ];
print ([ Mpath '\scripts\Matthieu\ProfileAnalysis\images\' dirname filename '.jpg'],'-djpeg')

dirname=['PerProfile\' num2str(i_transect) '\'];
filename=[ 'Profilesincecompletion' datestr(date(i_date),'YYYYmmdd') ];
print ([ Mpath '\scripts\Matthieu\ProfileAnalysis\images\' dirname filename '.jpg'],'-djpeg')
end

end
end
