% Create the requested graph output for acceleration and PSD
createAndSaveFigure(outputDir, 'acc_brr_x.jpg', t, brr_x, 'Acceleration Bracket Right X');
createAndSavePSDFigure(outputDir, 'psd_acc_brr_x.jpg', fxX, pxxX, 'PSD Bracket Right X', multg);

createAndSaveFigure(outputDir, 'acc_brr_y.jpg', t, brr_y, 'Acceleration Bracket Right Y');
createAndSavePSDFigure(outputDir, 'psd_acc_brr_y.jpg', fxY, pxxY, 'PSD Bracket Right Y', multg);

createAndSaveFigure(outputDir, 'acc_brr_z.jpg', t, brr_z, 'Acceleration Bracket Right Z');
createAndSavePSDFigure(outputDir, 'psd_acc_brr_z.jpg', fxZ, pxxZ, 'PSD Bracket Right Z', multg);



% Define the createAndSaveFigure function for acceleration
function createAndSaveFigure(outputDir, filename, t, acc, window, titleText)
    % Create a 1x2 subplot grid, and select the first subplot for acceleration
    subplot(1, 2, 1);
    plot(t, acc, 'b');
    grid on;
    xlabel('Time (s)');
    ylabel('Acceleration (m/s^2)');
    title(titleText);

    % Create a window plot on the right side
    subplot(1, 2, 2);
    plot(window);
    grid on;
    xlabel('X-axis Label');
    ylabel('Y-axis Label');
    title('Window Title');
    
    % Display the figure with both plots
    % You can comment out or remove the saveas lines if you don't want to save them.
    % saveas(gcf, fullfile(outputDir, filename)); % Comment out or remove this line
end

