refactor experiment config

This commit is contained in:
2026-02-01 11:08:04 -08:00
parent a965dff4ca
commit 79b03345ba
12 changed files with 180 additions and 97 deletions

View File

@@ -0,0 +1,42 @@
function targets = loadTargetsFromYaml(filename)
%LOADTARGETSFROMYAML Load target coordinates from YAML config file
% targets = loadTargetsFromYaml(filename) reads the targets section
% from a YAML config file and returns an Nx3 matrix of [x, y, z] coordinates.
targets = [];
fid = fopen(filename, 'r');
if fid == -1
error('Could not open file: %s', filename);
end
inTargets = false;
while ~feof(fid)
line = fgetl(fid);
if ~ischar(line)
break;
end
% Check if we've entered the targets section
if contains(line, 'targets:')
inTargets = true;
continue;
end
% If we hit another top-level key, exit targets section
if inTargets && ~isempty(line) && line(1) ~= ' ' && line(1) ~= '#'
break;
end
% Parse target entries: " - [x, y, z]"
if inTargets
% Extract numbers from array format
match = regexp(line, '\[\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\]', 'tokens');
if ~isempty(match)
coords = str2double(match{1});
targets = [targets; coords]; %#ok<AGROW>
end
end
end
fclose(fid);
end