MATLAB Function Reference
stairs

Stairstep plot

Syntax

• ```stairs(Y)
stairs(X,Y)
stairs(...,`LineSpec`)
[xb,yb] = stairs(Y)
[xb,yb] = stairs(X,Y)
```

Description

Stairstep plots are useful for drawing time-history plots of digitally sampled data systems.

```stairs(Y) ``` draws a stairstep plot of the elements of `Y`. When `Y` is a vector, the x-axis scale ranges from `1` to `size(Y)`. When `Y` is a matrix, the x-axis scale ranges from `1` to the number of rows in `Y`.

```stairs(X,Y) ``` plots `X` versus the columns of `Y`. `X` and `Y` are vectors of the same size or matrices of the same size. Additionally, `X` can be a row or a column vector, and `Y` a matrix with `length(X)` rows.

```stairs(...,LineSpec) ``` specifies a line style, marker symbol, and color for the plot (see `LineSpec` for more information).

```[xb,yb] = stairs(Y) and [xb,yb] = stairs(x,Y) ``` do not draw graphs, but return vectors `xb` and `yb` such that `plot(xb,yb)` plots the stairstep graph.

Examples

Create a stairstep plot of a sine wave.

• ``````x = 0:.25:10;
``````stairs(x,sin(x))
``````

`bar`, `hist`