def _spec_arg(k, kwargs, v):
    """
    Specify a default argument for constructors of classes created from .mat files.
    Used in autogenerated classes like ModelParameters.

    Parameters
    ----------
    k : string
        Name of variable whose value will be assigned

    kwargs : dict
        Dictionary of keyword arguments, which may or may not specify a value for k.  If the
        "mat_struct" field exists, then the value of k will be obtained by accessing the
        corresponding value inside the given MATLAB struct via kwargs["mat_struct"].k

    v : any
        Default value for the variable k.

    Returns
    -------
    The value to initialze the class with.
    """

    if k in kwargs:
        return kwargs[k]

    elif "mat_struct" in kwargs:
        return eval("kwargs[\"mat_struct\"]." + k)

    else:
        return v