Plot multiples of a variable

If I am plotting a square wave s.t.:

$Assumptions = {k, p} ∈ Reals && {k, p} > 0 f[x_] := Piecewise[{{2 k, 2 p < x < 4 p}, {0, 0 < x < 2 p}, {0, 4 p < x}}] Is there a way that I can plot this without setting k and p equal to something (for example 1)? An additional question, is there a way to evaluate f[x] without giving k and p values? E.g.: In:= f[3 p] Out= Piecewise[{{2 k, 2 p < 3 p < 4 p}, {0, True}}] would instead evaluate as In:= f[3 p] Out= 2 k Thank you all for you time, Edited to add that I am trying to make a plot similar to but with a square wave. Notice that the units for the range are multiples of E. • 1) There is no good way to plot f without assigning values for$p$and$k$; if the latter are not specified, then f is really a function of 3 variables; your best bet would then be some kind of ContourPlot3D. 2) Most functions don't take assumptions into consideration automatically; try perhaps Simplify[f[3 p]], or more directly Refine[f[3 p]] (which should be invoked automatically by Simplify anyway). – MarcoB Dec 6 '16 at 5:54 • ContourPlot3D is the wrong way to go about it. Looking to plot something with units as shown in this graphic: i.stack.imgur.com/iIQEL.gif – FoxForceFive Dec 6 '16 at 6:01 1 Answer Your assumption {k, p} > 0 is not equivalent to k > 0 && p > 0, likewise {k, p} ∈ Reals is not what you intend, but it's not necessary anyway, as it is implied by k > 0 && p > 0. So with$Assumptions = k > 0 && p > 0

you can do (as noted by @MarcoB)

Simplify[f[3 p]]
(* 2 k *)

A typical way to plot this type of thing is by rescaling to use dimensionless variables:

Plot[Simplify[f[x p]/k], {x, 0, 6}, AxesLabel -> {p, k}] If you want to explicitly label each tick with the units you can do

Plot[Simplify[f[x p]/k], {x, 0, 6},
Ticks -> {{1, p} # & /@ Range, {1, k} # & /@ Range[0, 2, .5]}
] • Thank you, this is exactly what I was looking for. – FoxForceFive Dec 7 '16 at 16:59