stairsCreate a stairstep plot of sine evaluated at 40 equally spaced values between 0 and 4π.
X = linspace(0,4*pi,40); Y = sin(X); figure stairs(Y) fig2plotly()
The length of
Yautomatically determines and generates the x-axis scale.
Create a stairstep plot of two cosine functions evaluated at 50 equally spaced values between 0 and 4π.
X = linspace(0,4*pi,50)'; Y = [0.5*cos(X), 2*cos(X)]; figure stairs(Y) fig2plotly()
The number of rows in
Yautomatically determines and generates the x-axis scale.
Create a stairstep plot of a sine wave evaluated at equally spaced values between 0 and 4π. Specify the set of x-values for the plot.
X = linspace(0,4*pi,40); Y = sin(X); figure stairs(X,Y) fig2plotly()
The entries in
Yare plotted against the corresponding entries inX.
Create a stairstep plot of two cosine waves evaluated at equally spaced values between 0 and 4π. Specify the set of x-values for the plot.
X = linspace(0,4*pi,50)'; Y = [0.5*cos(X), 2*cos(X)]; figure stairs(X,Y) fig2plotly()
The first vector input,
X, determines the x-axis positions for both data series.
Create a stairstep plot of two sine waves evaluated at different values. Specify a unique set of x-values for plotting each data series.
x1 = linspace(0,2*pi)'; x2 = linspace(0,pi)'; X = [x1,x2]; Y = [sin(5*x1),exp(x2).*sin(5*x2)]; figure stairs(X,Y) fig2plotly()
Each column of
Xis plotted against the corresponding column ofY.
Create a stairstep plot and set the line style to a dot-dashed line, the marker symbol to circles, and the color to red.
X = linspace(0,4*pi,20); Y = sin(X); figure stairs(Y, '-.or') fig2plotly()
Create a stairstep plot and set the line width to 2, the marker symbols to diamonds, and the marker face color to cyan using
Name,Valuepair arguments.
X = linspace(0,4*pi,20); Y = sin(X); figure stairs(Y,'LineWidth',2,'Marker','d','MarkerFaceColor','c') fig2plotly()
Starting in R2019b, you can display a tiling of plots using the
tiledlayoutandnexttilefunctions. Call thetiledlayoutfunction to create a 2-by-1 tiled chart layout. Call thenexttilefunction to create the axes objectsax1andax2. Create separate stairstep plots in the axes by specifying the axes object as the first argument tostairs.
x = linspace(0,2*pi); y1 = 5*sin(x); y2 = sin(5*x); tiledlayout(2,1) % Top plot ax1 = nexttile; stairs(ax1,x,y1) % Bottom plot ax2 = nexttile; stairs(ax2,x,y2) fig2plotly()
Create a stairstep plot of two data series and return the two stair objects.
X = linspace(0,1,30)'; Y = [cos(10*X), exp(X).*sin(10*X)]; h = stairs(X,Y); fig2plotly()
Use small circle markers for the first data series. Use magenta filled circles for the second series. Use dot notation to set properties.
h(1).Marker = 'o'; h(1).MarkerSize = 4; h(2).Marker = 'o'; h(2).MarkerFaceColor = 'm'; fig2plotly()
Evaluate two cosine functions at 50 equally spaced values between 0 and 4π and create a stairstep plot using
plot.
X = linspace(0,4*pi,50)'; Y = [0.5*cos(X), 2*cos(X)]; [xb,yb] = stairs(X,Y); fig2plotly()
stairsreturns two matrices of the same size,xbandyb, but no plot.Use
plotto create the stairstep plot withxbandyb.
figure plot(xb,yb) fig2plotly()