function make_variation_power() %MAKE_VARIATION_POWER Add a power-simulation script + result to every variation. % MAKE_VARIATION_POWER() copies variation_power.m into each % variations// folder that contains a data.csv (as powersim.m) and runs % it, producing power_result.txt beside the existing data.csv / analyze.m / % result.txt. Re-runnable; also picks up any folders added later. thisDir = fileparts(mfilename('fullpath')); template = fullfile(thisDir, 'variation_power.m'); root = fullfile(thisDir, 'variations'); d = dir(root); n = 0; for i = 1:numel(d) if ~d(i).isdir || ismember(d(i).name, {'.', '..'}); continue; end folder = fullfile(root, d(i).name); if ~exist(fullfile(folder, 'data.csv'), 'file'); continue; end copyfile(template, fullfile(folder, 'powersim.m')); fprintf('\n### %s ###\n', d(i).name); localRun(fullfile(folder, 'powersim.m')); n = n + 1; end fprintf('\nAdded powersim.m + power_result.txt to %d variation folders.\n', n); end function localRun(scriptPath) run(scriptPath); end