% cmc_muscle_forces.m
% Purpose:  Reads the set of motion files output by Darryl's executables
%           corresponding to subjectID and generates plots of the
%           RRA Residuals
%
% Input:    subjectID is the prefix ('string') of the following input files, 
%           generated from the preprocessing step and Darryl's executables:
%               subjectID.mot
%               subjectIDik.mot
%               subjectIDrea.mot
%               subjectIDcmc.mot
%
% Called Functions:  read_motionfile.m
%                    
% ASA, 3-05


% Set flag for printing (1 = print to printer; 0 = print to screen only)
close all
clear
clc

print_flag = 0;

% Set flag for pausing between figures (1 = pause, 0 = do not pause)
pause_flag = 0;



cmc_force = read_motionfile3('quickhop6_cmc_SLS_Actuation_force.sto');
% Read files subjectIDcmc.mot
% fname = strcat(subjectID, '_cmc.mot');
% fname = strcat(subjectID, '_cmc_presw2pk.mot');

% Generate plots
set(0, 'Units', 'pixels');
scnsize = get(0, 'ScreenSize');
scnwidth = scnsize(3);
scnheight = scnsize(4);
figpos_whole = [0.1*scnwidth, 0.4*scnheight, 0.8*scnwidth, 0.5*scnheight];
    

for i = 1:((cmc_force.nc-1)/9+1)
    figure()
    clf
    set(gcf, 'Position', figpos_whole, 'Color', 'w');
    set(gcf, 'PaperOrientation', 'landscape');
    set(gcf, 'PaperPosition', [1 1 9 6.5]);
    hold on
    k=1;
    for j = (9*i-7):(9*i+1)
        if j <= cmc_force.nc;
            
            subplot(3,3,k)
            p = plot(cmc_force.data(:,1), cmc_force.data(:,j));
            set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
            title_string = cmc_force.labels(j);
            title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
            xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
            ylabel('Force (N)', 'FontSize', 9, 'VerticalAlignment', 'bottom');
            set(gca, 'Box', 'off', 'FontSize', 8);
            ytickpositions = get(gca, 'Ytick');
            if length(ytickpositions) > 5
                new_ytickpositions = ytickpositions(1:2:length(ytickpositions));
                set(gca, 'Ytick', new_ytickpositions);
            end
        end
        k=k+1;
    end
end
        
