function out = rchg(val, ref)
%RCHG Computes the relative change of a value given a reference value.
%   If ref is given as a vector, val and ref must have the same size and
%   the relative change is computed element-wise.

    arguments
        val (:,1) double
        ref (:,1) double
    end

    if ~isscalar(ref) && numel(val) ~= numel(ref)
        error("Must give compatible number of values and reference values!");
    end

    out = 100 * (val ./ abs(ref) - 1);
end

