function [VolumeTotal, Beachwidth] = volumefind(x,z,shore) % Calculates Volume and Beach Width % Written by Matthew Phillips 2015 % Define Shoreline Contour and Fixed Landward Column Boundary ShoreCont = shore; % m AHD BackCol = 1; % column number if ~iscolumn(z) z = z'; end if ~iscolumn(x) x = x'; end if z(end) > z(1) z = flip(z); x = flip(x); end if x(end) < x(1) x = -x; end xstep = mean(diff(x)); shorecol = find(z>=ShoreCont,1,'last')+1; % Width at MSL Beachwidth = interp1(z(shorecol-1:shorecol,1),x(shorecol-1:shorecol,1),ShoreCont); % Total Volume Volx = [x(BackCol:shorecol-1); Beachwidth]; Volz = [z(BackCol:shorecol-1); ShoreCont]; VolumeTotal = trapz(Volx,Volz); end