

Since y contains two columns, Scilab understands that it must plot two lines in the graph, one each for each column of values. The number of rows in x and y must be the same.

Using the plot() function, we tell Scilab to look for values of x in the first variable (namely x) and look for values of y in the second variable (namely y). This must result in the following graph being plotted: >plot(x, y) xgrid(1) xtitle('Harmonic Functions', 'x', 'sin(x) and cos(x)') Then we will create the matrix y, containing the same number of rows as x, with values of sin(x) in its first column and values of cos(x) in its second column.

We will first create vector x, containing the values of the independent variable x. Let us plot a graph of sin(x) and cos(x) over the range x = 0 to 2 pi. Function plotting programs will decide the range of the values of independent variable and its data interval, generate the data on the fly and plot the graph. This is in contrast to function plotting programs (such as gnuplot) which plot graphs of functions without the user having to first explicitly generate the data required to plot the graph. Scilab is a data plotter, that is, it plots graphs from the data you input. In this session, we will learn the following functions: Plotting multiple graphs on one page (subplot()) In this session you will learn the following:Īnnotating graphs with grids, axis labels, graph titlesĮxporting graphs for inclusion in documents
