How to detect id a potentiometer is connected to a certain analog input

My software should behave different when a potentiometer is attached to A5.
My idea was to toggle the pullup-resistor and check what happens.

/*
 * is a poti connected to a certain analog input?
 */

const byte inputPin = A5;
const long dt1 = 100;
const long dt2 = 10;

void setup() {
  Serial.begin(9600);
  Serial.println(__FILE__);
}

boolean b;
long t = millis() + dt1;

void loop() {
  if (millis() > t) {
    b = !b;
    if (b) pinMode(inputPin,INPUT);
    else pinMode(inputPin,INPUT_PULLUP);
    t = t + dt1;
  }
  int v = analogRead(inputPin);
  //Serial.print("0 1024 ");
  Serial.println(v);
  delay(dt2);
}

But the results are not easy to process. This is what the Serial Plotter shows:

Anyone having a good idea how to say potentiometer is max or no potentiometer connected?

As there was no answer I had to solve it on my own.
It turned out that toggling INPUT_PULLUP was no good idea at all. Just leave pinMode as INPUT and read the incoming noise. A potentiometer if not turned by someone will give you readings that scatter about two or three. An open input will scatter much more. That's all.

I needed this detection to be able to develop a software which can either be used with an analog potentiometer or a digital one (also known as a rotary encoder). The end user can attach different shields without the need of reprogramming the Arduino.