function out = systrace(sys)
    arguments
        sys lti
    end

    n = size(sys);
    if any(diff(n))
        error("system not square")
    end
    n = n(1);
    
    out = 0;
    for i = 1:n
        out = out + sys(i, i);
    end
end
