In this example, we study the 'stem'
instruction to plot Matlab
It draws vertical lines (with a
little circle at the tip)
the value of the function at that particular horizontal value. 'stem' does not
the circles with a line, and it is very helpful to stress the fact that
continuous but discrete.
Let's assume that we want to plot the following elegant exponential and
let's draw a simple discrete function
We can develop a script like this:
Avoid superimposed operations and close previous figs.
clear; close all
First, we define 51 values of our independent variable
x = 0 :
2*pi/50 : 2*pi;
Second, we define the function to graph
exp(-x/3) .* sin(x);
Third, we use the 'stem' function to plot discrete values
We can add title and labels (as strings in arguments)
of the -stem- function')
And we get the following plot:
If we define our independant variable using less points, as in
x = 0 :
2*pi/20 : 2*pi;
we get the following visual change:
'Matlab Plot' to
Plot' to '2D Plot Menu'