leftimage for poohprod.ru

Scilab 2D plots

This is a brief introduction to the great potential of Scilab’s graphic capabilities. We’ll review a few of the basic commands and operations to carry out this important task in sofisticated software like Scilab or Scicoslab.

Simple Graphic Representation

In a simple graphic representation we just need two vectors with the same number of elements. The idea is to show a mathematical relationship or function that results in a 2D graph. The built-in functions that allow us to do that are plot and plot2d.

The following functions are quite compatible with Matlab:

  • plot
  • subplot
  • xlabel
  • ylabel
  • legend
  • title

These functions are different from the Matlab ones:

  • xdel(n) – deletes a figure window
  • scf(n) – opens a figure window
  • xgrid – shows a grid on the plot
  • ax = get("current_axes"); ax.data_bounds = [xL, yL; xU, yU]; - it’s an approximation of the Matlab axis function

This code

x = -10 : .1 : 10; / our independent values
y = cos(x) .* x; / define our dependent values
plot(x, y) / both vectors

xlabel('x'); ylabel('y'); / define labels
legend('y = cos(x) * x'); / define legend
title('My First Scilab 2D Plot') / title

produces this Scilab plot

Scilab 2D plots - basic functions

We can re-define the axis values and add a grid by adding these lines to the previous code:

/ the handle of the newly created axes
ax = get("current_axes");

/ axes
ax.data_bounds = [-10, -6; 10, 8];

/ grid

The resulting plot is

Scilab grid and bounded axes

To erase the contents of one figure window, you only need to type the command clf in the command line, or you can select Erase Figure in the edit menu of the figure selected.

If you want to generate new plots without removing the previous one, it’s necessary to indicate the creation of a new one using the command ‘scf’, whose syntax is scf(integer number of the new plot).

If you run the code below

x = -10 : .1 : 10; / define our independent values
y = cos(x) .* x; / our dependent values
y2 = 3 * sin(x); / another function
plot(x, y,'b', x, y2, 'r')

xlabel('x'); ylabel('y'); / define labels
legend('y = cos(x) * x', 'y2 = 3 sin(x)'); / define legend

you can see two lines in the same window, each with a different legend and color

Scilab - two functions in one window

From 'Scilab 2D Plots' to Matlab home

From 'Scilab 2D Plots' to Scilab


footer for matlab page

Related pages

matlab lessonsmatlab plot polynomialmatrix equation solver matlabbisection method examples with solutionssurf matlabconvert from octal to decimalmatlab trapezoidal methodrgb color matlabdiscrete distribution calculatorhex to dec tablesum of fibonacci numbers formulamatlab financeslope intercept form from two points calculatorlog10 matlablinear regression with matlabpascal triangle code in cquadratics equation solversimple interest calccode for pascal trianglematlab 2d plotascii code for alphabets and numbers3 bit binary to gray code converterc program for sine seriessquare root approximation formulaimpulse functionmatlab piecewise functionprogram for pascal triangle in c using for loopmatlab algebraprime factorization examplecalculation for bmigoogle integral calculatorwhat is heaviside functiondirac delta function examplesmatlab surfcexponential growth or decay calculatorhow to write unit step function in matlabpiecewise function calculator onlinebinary to hexadecimal methodbinary number to octalsolver matlabimpedance admittance smith chartcompound continuous calculatorconvert cartesian to cylindricalwhat does piecewise meandepreciation calcbinary converter to octalintegral calculaterwriting a matlab programfzero matlab examplefibonacci number generatoreven odd matlaberrordlg matlabsawtooth harmonicsmatlab solve linear equationxlabel in matlabsimultaneous equations in matlabintegral calculator definitematlab animation exampleexample of a piecewise functionmatlab lagrangewhat is scrap value in depreciationinverse matlabsalvage value and scrap value3d plot matlabinterest amortization tablesbinary to decimal conversion algorithmquick way to find inverse of 3x3 matrixtrapezoidal matlabhow to graph piecewise functions on calculatorexp matlabpolar histogrammatrix multiplication in matlab