
STEM Plots in Octave
In this lesson, I will explain how to create a STEM plot on Octave.
What is a STEM plot? It is a plot where the points of a function are represented by equidistant stems. This way, a continuous function is discretely represented. Here is a practical example of a STEM graph.
Let me give you a practical example.
Create an array "x" of the independent variable with values from 1 to 20.
>> x=linspace(1,20,20);
Then create an array "y" for the function y=x^2.
>> y=x.^2
Now, plot the function using the function plot().
>> plot(x,y)
The function is drawn on the Cartesian diagram continuously.
To represent the same function in a STEM plot, use the command stem(x,y) or stem(y).
>> stem(x,y)
This command draws the function using a STEM plot.
It is an alternative way to represent the same function.
If this Nigiara lesson has helped you, keep following us.