function analyze_this(info, dirs)

% read measurements
t = load('t.asc');
x = load('x.asc');
z = load('z.asc');

if size(x,2)>1
    x0 = unique(x(:)); x0 = x0(~isnan(x0));
    z0 = nan(length(x0),size(x,2));
    for i = 1:size(x,2)
        notnan  = find(~isnan(x(:,i)));
        
        [ux ui] = unique(x(notnan,i));
        uz      = z(notnan(ui),i);
        
        [sx si] = sort(ux);
        sz      = uz(si);
	    
        z0(:,i) = interp1(sx,sz,x0);
    end
    x = x0;
    z = z0;
end

xD = []; zD = [];
if exist('xDUROSTA.asc', 'file')
    xD = load('xDUROSTA.asc');
    zD = load('zDUROSTA.asc');
end

% read dimensions
d       = xb_read_dims;
[m i]   = closest(1000+t*3600, d.t);

% read input
xbi     = xb_read_input(pwd);
zs0     = max([0 xs_get(xbi,'zs0') max(xs_get(xbi,'zs0file.tide'))]);

% read output
xbo1    = xb_read_output(pwd, 'vars', {'zb'}, 'index', i-1);
xbo2    = xb_read_output(pwd, 'vars', {'zb'});

% analyze output
xbb     = xb_get_morpho(xbo2, 'level', zs0);

% plot output
id = find(strcmp({xbb.data.name}, 'ero'),1); % find which row contains 'ero'
xbb.data(id).value = abs(xbb.data(id).value); %take abs of erosion - seems to solve problem with pictures, quick & dirty fix
id2 = find(strcmp({xbb.data.name}, 'R'),1); % find which row contains 'R'
xbb.data(id2) = []; % remove row of 'R' to prevent making a 3rd subplot with 'retreat distance'
xb_plot_morpho(xbb);

xb_write_plot(gcf, dirs.output, 'fig2');

xb_write_skilltable(xbo1, {[x z(:,end)]}, 'vars', 'zb', 'file', fullfile(dirs.output, 'skills.tex'));

% remove all but the first and last outputs
for iv = 2:length(xbo1.data)
    if length(size(xbo1.data(iv).value)) == 3
        xbo1.data(iv).value = xbo1.data(iv).value([1 end],:,:);
    end
end

xb_plot_profile(xbo1,'measured',[x z(:,end)], 'durosta', [xD zD])
title(['profiles ' info.test ' ' info.run], 'interpreter', 'none')
xb_write_plot(gcf, dirs.output, 'final_profiles')
