function [timeMillis, values] = loadAndProcessCSV(filename)
    validateattributes(filename, {'char', 'string'}, {'scalartext'}, mfilename, 'filename');

    if ~isfile(filename)
        error('Input CSV file not found: %s', filename);
    end

    data = readtable(filename, 'ReadVariableNames', false, 'HeaderLines', 1, 'Format', '%s%s');

    timeMillis = zeros(height(data), 1);
    values = zeros(height(data), 1);

    for idx = 1:height(data)
        timeParts = split(string(data.Var1{idx}), ':');
        if numel(timeParts) ~= 3
            error('Invalid timestamp format on row %d. Expected mm:ss:ms.', idx + 1);
        end

        minutes = str2double(timeParts{1});
        seconds = str2double(timeParts{2});
        millis = str2double(timeParts{3});
        sampleValue = str2double(data.Var2{idx});

        if any(isnan([minutes, seconds, millis, sampleValue]))
            error('Encountered non-numeric data on row %d.', idx + 1);
        end

        timeMillis(idx) = (minutes * 60 + seconds) * 1000 + millis;
        values(idx) = sampleValue;
    end
end
