


define a new function which calls the first one.provide the data to the contour function by using feval,.provide the data to the contour function by making two nested loops,.There are two possibilities to solve this little problem: The problem is that there is only one single input argument, instead of the two arguments required by the contour function. In practice, it may happen that our function has the header z = myfunction ( x ), where the input variable x is a row vector.

This produces the contour plot presented in figure 22.įigure 22: Contour plot of the function f(x1,x2) = x1^2 + x2^2. The linspace function is used to generate vectors of data so that the function is analyzed in the range ^2.Ĭontour ( xdata, ydata, myquadratic2arg, 10) The myquadratic function takes two input arguments x1 and x2 and returns f(x1,x2) = x1^2 + x2^2. In the following Scilab session, we use a simple form of the contour function, where the function myquadratic is passed as an input argument.

In this section, we present the contour plots of a multivariate function and make use of the contour function. When the number of points to manage is large, using functions directly saves significant amount of memory space, since it avoids generating the intermediate vector ydata. Indeed, the second input argument of the plot function can be a function, as in the following session. Notice that we could have produced the same plot without generating the intermediate array ydata. We finally use the plot function so that the data is displayed as an x-y plot.įigure 21 presents the associated x-y plot. This produces the row vector ydata, which contains 50 entries. We can pass it to the myquadratic function and get the function value at the given points. The xdata variable now contains a row vector with 50 entries, where the first value is equal to 1 and the last value is equal to 10. We can use the linspace function in order to produce 50 values in the interval. The myquadratic function squares the input argument x with the ”ˆ”operator. We begin by defining the function which is to be plotted. We emphasize the use of vectorized functions, which produce matrices of data in one function call.
#MATRIX IN SCILAB HOW TO#
In this section, we present how to produce a simple x-y plot. linspaceĬonfigure the title and the legends of the current plotįigure 20: Scilab functions used when creating a plot. The functions presented in figure 20 will be used in the examples of this section. In order to get an example of a 3D plot, we can simply type the statement surf() in the Scilab console.ĭuring the creation of a plot, we use several functions in order to create the data or to configure the plot. The most commonly used plot functions are presented in figure 19. It can create x-y plots with the plot function, contour plots with the contour function, 3D plots with the surf function, histograms with the histplot function and many other types of plots. Scilab can produce many types of 2D and 3D plots. We finally export the plots so that we can use it in a report. Then we customize the title and the legend of our graphics. In this section, we present how to create 2D plots and contour plots. Scilab offers many ways to create and customize various types of plots and charts. Producing plots and graphics is a very common task for analysing data and creating reports.
