stem3Create a 3-D stem plot of cosine values between -π/2 and π/2 with a row vector input.
figure X = linspace(-pi/2,pi/2,40); Z = cos(X); stem3(Z) fig2plotly()
stem3plots elements ofZagainst the same y value at equally space x values.
Create a 3-D stem plot of cosine values between -π/2 and π/2 with a column vector input.
figure X = linspace(-pi/2,pi/2,40)'; Z = cos(X); stem3(Z) fig2plotly()
stem3plots elements ofZagainst the same x value at equally space y values.
Create a 3-D stem plot of sine and cosine values between -π/2 and π/2 with a matrix input.
figure X = linspace(-pi/2,pi/2,40); Z = [sin(X); cos(X)]; stem3(Z) fig2plotly()
stem3plots each row ofZagainst the same y value at equally space x values.
Create a 3-D stem plot and specify the stem locations along a curve. Use
viewto adjust the angle of the axes in the figure.
figure X = linspace(-5,5,60); Y = cos(X); Z = X.^2; stem3(X,Y,Z) view(-8,30) fig2plotly()
XandYdetermine the stem locations.Zdetermines the marker heights.
Create a 3-D stem plot with matrix data and specify the stem locations in the xy-plane.
figure [X,Y] = meshgrid(0:.1:1); Z = exp(X+Y); stem3(X,Y,Z) fig2plotly()
XandYdetermine the stem locations.Zdetermines the marker heights.
Create a 3-D stem plot of cosine values between -π and π and fill in the markers.
X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'filled') fig2plotly()
Create a 3-D stem plot of cosine values between -π and π. Use a dashed line style for the stem, set the marker symbols to stars, and set the color to magenta.
figure X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'--*m') fig2plotly()
To specify only two of the three
LineSpecoptions, omit the third option from the character vector. For example,'*m'sets the marker symbol and the color and uses the default line style.
Create a 3-D stem plot and specify the stem locations along a circle. Set the stem to a dotted line style, the marker symbols to stars, and the color to magenta.
figure theta = linspace(0,2*pi); X = cos(theta); Y = sin(theta); Z = theta; stem3(X,Y,Z,':*m') fig2plotly()
XandYdetermine the stem locations.Zdetermines the marker heights.
Create a 3-D stem plot of cosine values between -π and π. Set the marker symbols to squares with green faces and magenta edges.
figure
X = linspace(-pi,pi,40);
Z = cos(X);
stem3(Z,'Marker','s',...
'MarkerEdgeColor','m',...
'MarkerFaceColor','g')
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 stem plots in the axes by specifying the axes object as the first argument tostem3.
X = linspace(-2,2,50); Y = X.^3; Z = exp(X); tiledlayout(2,1) % Top plot ax1 = nexttile; stem(ax1,X,Z) % Bottom plot ax2 = nexttile; stem3(ax2,X,Y,Z) fig2plotly()
Create a 3-D stem plot and return the stem series object.
X = linspace(0,2); Y = X.^3; Z = exp(X).*cos(Y); h = stem3(X,Y,Z,'filled'); fig2plotly()
Change the color to magenta and set the marker face color to yellow. Use
viewto adjust the angle of the axes in the figure. Use dot notation to set properties.
h.Color = 'm'; h.MarkerFaceColor = 'y'; view(-10,35) fig2plotly()