subject='subject01';
trial='walk01';
%subject='delaware3';
%trial='ss_walking1';
pertWindow=0.03;
pertDF=1.0;

%bodyacc=read_motionFile(sprintf('%s_%s_unpert_BodyKinematics_acc.sto',subject,trial));
bodyacc=read_motionFile(sprintf('ResultsForward/%s_%s_BodyKinematics_acc.sto',subject,trial));
deltaA(1)=read_motionFile(sprintf('ResultsPerturb/center_of_mass_X_deltaA_dt_%.3f_df_%.3f.sto',pertWindow,pertDF));
deltaA(2)=read_motionFile(sprintf('ResultsPerturb/center_of_mass_Y_deltaA_dt_%.3f_df_%.3f.sto',pertWindow,pertDF));
deltaA(3)=read_motionFile(sprintf('ResultsPerturb/center_of_mass_Z_deltaA_dt_%.3f_df_%.3f.sto',pertWindow,pertDF));

tmin=deltaA(1).data(1,1);
tmax=deltaA(1).data(end,1);
I=find(bodyacc.data(:,1)>=tmin & bodyacc.data(:,1)<=tmax);
bodyacc.data = bodyacc.data(I,:);

bodyaccIndices=find_columns_by_label(bodyacc.labels,'center_of_mass');
axes={'X','Y','Z'};

for i = 1:3
    figure;
    plot(bodyacc.data(:,1), bodyacc.data(:,bodyaccIndices(i)), 'g');
    hold on;
    plot(deltaA(i).data(:,1), sum(deltaA(i).data(:,2:end),2), 'r');
    %plot(deltaA(i).data(:,1), deltaA(i).data(:,2:end), 'b');
    legend({'BodyAcc','Sum',deltaA(i).labels{2:end}});
    legend off;
    title(sprintf('Body acceleration %s', axes{i}));
end
