Professional Documents
Culture Documents
2D Plotting
2D Plotting
2D Plotting
2D Plotting
Reference:
- Sandeep Nagar, Introduction to Scilab For Engineers and Scientists
4.1 Introduction
Without visualization, numerical computations are difficult to
understand and eventually judge. Producing publication-quality images
of complex plots that give a meaningful analysis of numerical results
has been a challenge for scientists all over the world.
Many commercial softwares satisfy this need. Scilab also provides this
facility quite efficiently.
4.1 Introduction
Its plotting features includes choosing from various types of plots in 2D
and 3D regimes; decorating plots with additional information such as
titles, labeled axes, grids, and data labels; and writing equations and
other important information about the data.
The following sections will describe these actions in detail. It is worth
mentioning that plotting capabilities are essential to certain numerical
analysis experiments since visual directions from the progressive steps
give an intuitive understanding of the problem under consideration.
4.2 2D Plotting
plot(x,y)
Since we need data on two axes to be plotted, we first need to create
them.
Let’s assume that the x-axis has 100 linearly spaced data points and the
points on the y-axis are defined by an equation, as illustrated in Figure
4-1:
4.2 2D Plotting
4.2 2D Plotting
First, we define a variable x and place 100 equally spaced data points
from 0 to 100. This makes a 1 x 100 matrix.
Using a scalar operation of exponentiation, we define a variable y as x2.
It is important to note that this operation is defined using an
elementwise operator so that each element of matrix x is operated by
the operator.
Without this approach, the array would have to be squared, that is,
multipled by itself. This would produce an error since an n × m matrix
can only be multipled by a m × n matrix.
Finally, one can use the function plot(), which takes two arguments as
the x-axis and y-axis data points.
4.2 2D Plotting
Typing help plot or help'plot' at the command prompt gives useful
insight into this wonderful function written to plot two-dimensional
data.
By default, successive plots are superposed. To clear the previous plot,
use clf(). Also, the plot function can evaluate the input arguments:
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2 2D Plotting
4.2.3 polarplot()
During mathematical analysis, polar coordinates become important in
cases that do not exhibit symmetry in Cartesian systems, but that show
symmetry in polar coordinates.
In these cases, we prefer to plot in polar coordinates rather than
Cartesian coordinates. So, instead of x, y our coordinates are r, θ, which
are related by equations, as shown in Figures 4-6 and 4-7.
4.2.3 polarplot()
4.2.3 polarplot()