files = { 'Results/delaware3_ss_walking1_ik_Actuation_force.sto', 'Results/reduced_average/delaware3_ss_walking1_ik_rra_Actuation_force.sto', 'Results/delaware3_ss_walking1_ik_rra_Actuation_force.sto', 'ResultsCMC/delaware3_actuation_force.sto' };

for f=1:4

if ~exist(files{f},'file')
	continue;
end

q=read_motionFile(files{f});

T=q.data(:,1);
scrsz = get(0,'ScreenSize');
figure('Position',[20 20 1024 768], 'Color',[1 1 1]);
axes('FontSize',20);

xmin=min(T);
xmax=max(T);

ymin=min(min(q.data(:,2:4)));
ymax=max(max(q.data(:,2:4)));

if f==1
	Faxes=[xmin xmax ymin ymax];
end

labels={'Fx','Fy','Fz'};
for i=1:3
	subplot(2,3,i);
	plot(T,zeros(length(T),1),'g','LineWidth',0.5);
	hold on;
	plot(T,q.data(:,1+i),'LineWidth',2);
	hold off;
	title(labels{i},'FontSize',20);
	axis(Faxes);
end

ymin=min(min(q.data(:,5:7)));
ymax=max(max(q.data(:,5:7)));

if f==1
	Maxes=[xmin xmax ymin ymax];
end

labels={'Mx','My','Mz'};
for i=1:3
	subplot(2,3,3+i);
	plot(T,zeros(length(T),1),'g','LineWidth',0.5);
	hold on;
	plot(T,q.data(:,4+i),'LineWidth',2);
	hold off;
	title(labels{i},'FontSize',20);
	axis(Maxes);
end

disp(sprintf('printing %d', f));
print('-depsc2','-r300',sprintf('residuals_%d',f));

end
