# Staircase Ramp Function

How is a linear ramp StairCase Function defined with given uniform $n$ steps in domain? The Floor function forces a unit increment on the x or t independent variable, so not suitable. Thanks.

EDIT

After the below and @Kubs's comment it is seen to work, but I mistook earlier about inaccuracy from its plot, but it is ok in the Table.

xm = 2 Pi; dx = Pi/4.; Plot[Floor[x, dx]/xm, {x, 0, xm},
GridLines -> Automatic]
i = 0; Table[{i++, x, Floor[x, dx]/xm}, {x, 0, xm, dx}] // TableForm

• Can't you rescale x? – Kuba Nov 22 '16 at 14:33
• Can you give some minimal example what the function should produce? This makes it easier for people to reason about the problem and come up with ideas for a solution. – Thies Heidecke Nov 22 '16 at 14:51
• @Kuba Thanks, It works. Actually I thought it does not give $1$ on $y$ in the staircase plot. – Narasimham Nov 22 '16 at 15:25
• ListStepPlot[Table[{n*Pi/4, n/8}, {n, 0, 7}], Joined -> False, GridLines -> Automatic] – Bob Hanlon Nov 22 '16 at 16:15

That should work:

NN = 7;
xmax = 20;
Plot[Floor[NN/xmax*x], {x, 0, xmax}]


With NN the number of steps and xmax the end of the domain. • Your solution gives out in xmax 6 instead of 1. You should normalize it! – Mirko Aveta Nov 22 '16 at 15:23

Is it this you are looking for?

Staircase[n_, x0_] := Sum[HeavisideTheta[x - (i/n) x0], {i, 0, n}]/n
Plot[Staircase[5, 1], {x, 0, 1}] With 12 steps, it would be:

Plot[Staircase[12, 1], {x, 0, 1}] 