function [time,u_errors,v_errors,rho_errors] = err_merge (time_pri,u_errors_pri,v_errors_pri,rho_errors_pri, ...
                                                          time_pos,u_errors_pos,v_errors_pos,rho_errors_pos);
t1 = time_pri;

urms1 = u_errors_pri.rms;
uabs1 = u_errors_pri.abs;
umax1 = u_errors_pri.max_abs;
umin1 = u_errors_pri.min_abs;

vrms1 = v_errors_pri.rms;
vabs1 = v_errors_pri.abs;
vmax1 = v_errors_pri.max_abs;
vmin1 = v_errors_pri.min_abs;

rhorms1 = rho_errors_pri.rms;
rhoabs1 = rho_errors_pri.abs;
rhomax1 = rho_errors_pri.max_abs;
rhomin1 = rho_errors_pri.min_abs;

t2 = time_pos;

urms2 = u_errors_pos.rms;
uabs2 = u_errors_pos.abs;
umax2 = u_errors_pos.max_abs;
umin2 = u_errors_pos.min_abs;

vrms2 = v_errors_pos.rms;
vabs2 = v_errors_pos.abs;
vmax2 = v_errors_pos.max_abs;
vmin2 = v_errors_pos.min_abs;

rhorms2 = rho_errors_pos.rms;
rhoabs2 = rho_errors_pos.abs;
rhomax2 = rho_errors_pos.max_abs;
rhomin2 = rho_errors_pos.min_abs;

time = [];
urms = [];
uabs = [];
umax = [];
umin = [];

vrms = [];
vabs = [];
vmax = [];
vmin = [];

rhorms = [];
rhoabs = [];
rhomax = [];
rhomin = [];


while ( ~isempty(t1) & ~isempty(t2) )
    ind = find (t1<=t2(1));

    time = [time; t1(ind); t2(1)];

    urms = [urms; urms1(ind); urms2(1)];
    uabs = [uabs; uabs1(ind); uabs2(1)];
    umax = [umax; umax1(ind); umax2(1)];
    umin = [umin; umin1(ind); umin2(1)];

    vrms = [vrms; vrms1(ind); vrms2(1)];
    vabs = [vabs; vabs1(ind); vabs2(1)];
    vmax = [vmax; vmax1(ind); vmax2(1)];
    vmin = [vmin; vmin1(ind); vmin2(1)];

    rhorms = [rhorms; rhorms1(ind); rhorms2(1)];
    rhoabs = [rhoabs; rhoabs1(ind); rhoabs2(1)];
    rhomax = [rhomax; rhomax1(ind); rhomax2(1)];
    rhomin = [rhomin; rhomin1(ind); rhomin2(1)];


    t1(ind) = [];
    urms1(ind) = [];
    uabs1(ind) = [];
    umax1(ind) = [];
    umin1(ind) = [];

    vrms1(ind) = [];
    vabs1(ind) = [];
    vmax1(ind) = [];
    vmin1(ind) = [];

    rhorms1(ind) = [];
    rhoabs1(ind) = [];
    rhomax1(ind) = [];
    rhomin1(ind) = [];

    t2(1) = [];
    urms2(1) = [];
    uabs2(1) = [];
    umax2(1) = [];
    umin2(1) = [];

    vrms2(1) = [];
    vabs2(1) = [];
    vmax2(1) = [];
    vmin2(1) = [];

    rhorms2(1) = [];
    rhoabs2(1) = [];
    rhomax2(1) = [];
    rhomin2(1) = [];

end;

if ~isempty(t1)
    time = [time; t1];

    urms = [urms; urms1];
    uabs = [uabs;  uabs1];
    umax = [umax; umax1];
    umin = [umin; umin1];

    vrms = [vrms; vrms1];
    vabs = [vabs; vabs1];
    vmax = [vmax; vmax1];
    vmin = [vmin; vmin1];

    rhorms = [rhorms; rhorms1];
    rhoabs = [rhoabs; rhoabs1];
    rhomax = [rhomax; rhomax1];
    rhomin = [rhomin; rhomin1];
end;

if ~isempty(t2)
    time = [time; t2];

    urms = [urms; urms2];
    uabs = [uabs;  uabs2];
    umax = [umax; umax2];
    umin = [umin; umin2];

    vrms = [vrms; vrms2];
    vabs = [vabs; vabs2];
    vmax = [vmax; vmax2];
    vmin = [vmin; vmin2];

    rhorms = [rhorms; rhorms2];
    rhoabs = [rhoabs; rhoabs2];
    rhomax = [rhomax; rhomax2];
    rhomin = [rhomin; rhomin2];
end;


u_errors = struct ('rms',urms, ...
                   'abs',uabs, ...
                   'max_abs',umax, ...
                   'min_abs',umin);

v_errors = struct ('rms',vrms, ...
                   'abs',vabs, ...
                   'max_abs',vmax, ...
                   'min_abs',vmin);

rho_errors = struct ('rms',rhorms, ...
                     'abs',rhoabs, ...
                     'max_abs',rhomax, ...
                     'min_abs',rhomin);

