function b = ndtrace(A)
%TRACE ndarray variant of trace
    arguments
        A (:,:,:) {mustBeNumeric}
    end
    
    b = squeeze(zeros([size(A, 3) 1]));
    for i = 1:numel(b)
        b(i) = trace(A(:,:,i));
    end
end
