Difference between stem and plot command in matlab
Answers
Answered by
9
when you want to plot several graphs at one place together you use the function subplot().
it's syntax is subplot(num_of_rows,num_of_columns,posit...
position of the figure means the place where the figure is to be plotted.Counting starts from the 1st row,1st column and goes rightwards row-wise.
num_of_rows stands for the number of figures you want to plot in a column.
num_of _columns stands for the number of figures you want to plot in a row.
STEM:
Normally whenever we draw a graph we join each of the neighbouring points with one another.But using stem function you plot the discrete functions,i.e.,without joining the coordinates.If you want to join the points use the plot() function.
They have the same syntax:
plot(x,y);
stem(x,y)
You can try using both plot and stem functions at same place using subplot.
In your program,I don't it's proper syntax because you cannot plot two graphs in one figure(remember figure not place).
subplot(4,1,4)
stem(n,xo)
plots discrete graph in a page where 4 rows and 1column of figures can be inserted.And the position for the figure is 4th from the start,i.e.,last row and first column.But in order to plot the next graph on the same figure you have to use hold on:
subplot(4,1,4)
stem(n,xo)
hold on
plot(t,x)
hold off
Or if you want to plot two different figures try this:
subplot(4,1,3)
stem(n,xo)
subplot(4,1,4)
plot(t,x)
it's syntax is subplot(num_of_rows,num_of_columns,posit...
position of the figure means the place where the figure is to be plotted.Counting starts from the 1st row,1st column and goes rightwards row-wise.
num_of_rows stands for the number of figures you want to plot in a column.
num_of _columns stands for the number of figures you want to plot in a row.
STEM:
Normally whenever we draw a graph we join each of the neighbouring points with one another.But using stem function you plot the discrete functions,i.e.,without joining the coordinates.If you want to join the points use the plot() function.
They have the same syntax:
plot(x,y);
stem(x,y)
You can try using both plot and stem functions at same place using subplot.
In your program,I don't it's proper syntax because you cannot plot two graphs in one figure(remember figure not place).
subplot(4,1,4)
stem(n,xo)
plots discrete graph in a page where 4 rows and 1column of figures can be inserted.And the position for the figure is 4th from the start,i.e.,last row and first column.But in order to plot the next graph on the same figure you have to use hold on:
subplot(4,1,4)
stem(n,xo)
hold on
plot(t,x)
hold off
Or if you want to plot two different figures try this:
subplot(4,1,3)
stem(n,xo)
subplot(4,1,4)
plot(t,x)
Similar questions