

There are also some build-in functions within Scilab for matrix editing. This time to the matrix C we have assigned value 5 from row 2 to 3 and from column 2 to 3.īy practising these example you should be able to extract and edit Scilab vectors and matrices. Here we have defined matrix B with 3 rows and 3 columns and we assigned value 8 to the 3rd row and columns from 1 to 3. In this example we added a third row to matrix “A” containing four elements of 9.Īnother way for matrix definition is by specifying the number of columns and rows which have assigned a value. Also it gives the possibility of adding new rows or columns to the matrices. Using the variable editor allows us to change as many values of the matrix as we want. Only the dimension is different between them, all variable are of type “Double”: Keep in mind that for Scilab there is no difference between a vector or a matrix. Or by inserting the elements of the column using the “ ” terminator: ->V2= We can define the vector either by inserting the elements of the row: ->V1= If not Scilab will output a error message: ->C=Ī vector is in fact a matrix but only with one row or column. function output arguments functionname(input arguments) instructions. If the first row has 4 elements, for exemple, the second row has to have the same length. Sparse matrices can be easily performed on Scilab. The matrix definition has to be consistent. In the same way a 2×4 matrix can be defined: ->B= In the same manner rows 2 and 3 are defined. In order to complete the definition of the first row “ ” is used. First are entered the values for the first row “1 2 3”. In Scilab, a variable of type matrix is defined in the following way: ->A= It has a lot of built-in functions that allows the user to perform complex computations and manipulations on vectors (1-D matrices) and matrices. About it we’ll discuss in another article.įor any questions, observations and queries regarding this article, use the comment form below.As Matlab®, Scilab is very powerful at computations with variables such as vectors and matrices. The disp function is easy to use and very useful in the early stages of of the script/program design.Ī more versatile function for data display is the mprintf function. Display a Scilab list variable ->var_list = list(,) Pay attention to the order of the display (LIFO).Ħ. kg', var_mass, 'The mass of the body is ')

>disp('The mass of the body is ', var_mass, ' kg.') Display multiple variables with different type (scalar and string) ->var_mass = 34 Display a random matrix ->var_mtx = rand(5,3) ĥ.
SCILAB OUTPUT MATRIX MOVIE
Display a string with special characters (quotes) ->var_str_spe = 'The movie ''Random movie name'' was good' Ĥ. Display a string ->var_str = 'Some random string' ģ.
SCILAB OUTPUT MATRIX HOW TO
Here are several examples on how to use the disp function:Ģ. If there are several variables to be displayed, the first one shown in the Scilab console is the last in the function arguments (LIFO – Last In First Out). The variables to be displayed can be of type: xN, without printing also the variable name. In the simplest form, the disp function prints in the Scilab console only the value of the variables x1, x2.


For this objective we can use the Scilab built-in disp function, which is easy to understand and quite flexible. While programming in Scilab, during program design phase, we need to print result in the Scilab console mainly for debug purposes.
