Question: Plotting a function with if statement does not work. Why ?

Dear forum,

my name is Klaus, I am a former mathcad-user and new to maple. I try to get some sheets converted and found a maple-behaviour I don't understand.

I made up a simple function with an if statement. When I try different inputs by hand, I get correct results.
But if I try to plot it, I get the message that the if-statement does not work.

My question : How can I solve this ? And what is the difference between plotting a function and entering values manually ?

restart;
with(Units[Simple]);

funktion := x -> if 2*Unit('m') < x then 1/x; else 2*Unit('m'); end if;

r1 := 3.0*Unit('m');

r2 := 6*Unit('m');

plot(funktion(x), x = r1 .. r2);
Error, (in funktion) cannot determine if this expression is true or false: 2 < x*Units:-Unit(1/m)

Please Wait...