```python
def is_undulating(n):
    """
    Checks if a number is undulating.
    An undulating number has three or more digits and its digits alternate
    between two distinct values (e.g., 131, 25252).
    """
    s = str(n)

    # An undulating number must have at least three digits.
    if len(s) < 3:
        return False

    # The first two digits establish the pattern and must be different.
    if s[0] == s[1]:
        return False

    # Check if the rest of the digits follow the pattern s[i] == s[i-2].
    for i in range(2, len(s)):
        if s[i] != s[i - 2]:
            return False

    return True
```