
Environment Variablesįor internal purposes Scilab uses some environment variables. Hint: Instead of %i, the Scilab user can use sqrt(-1). A part of these variables are defined in the scilab.start file which can be found in SCI + “/etc” folder. These special Scilab variables are considered predefined, they can not be deleted nor saved using the save function. If you try to assign a different value to any of them, Scilab will output an error message without taking into account the instruction: ->%pi=5 The values of these variables can not be changed, they are protected to writing. In order to access these variable the character „%” must be used at the beginning of the name.

The names suggest that these variables can not change their values, they are constant.

In Scilab are defined some special variables which are called constants. Where T is a Scilab Boolean variable for „true”. More, if we want to check if Scilab is interpreting 3.6000000000000000888178 as 3.6 we will use the following code: ->3.6 = var1 You can clearly see that 3.6 is not represented exactly but approximately with a very good precision. In order to see the approximation for the example above we will change the display format of the variable to see the maximum number of digits: ->format(25) Nevertheless the variable coding within Scilab is sufficient for the most of the applications. That means that the calculation done in Scilab are not exact but with a very good accuracy. Since all the variables are coded in a specific format they have an representation error. So if you don’t specify the data type of the variable, Scilab will store it as double. This was not normally possible with a function (see example with cos).Įven if it’s not recommended from the readability point of view, you can define a Scilab variable name as: ->%#?!$_ = 123ĭefault coding for Scilab variables is in double precision, on 64 bits. Scilab warned me about this function redefining! After sin declaration I can used it as an ordinary variable. In the example above we have created a variable named sin which will be used as a variable instead as a trigonometric function. Undefined operation for the given operands.Ĭheck or define function %fptr_a_s for overloading. So if you name your variable the same as a function, Scilab will use the variable instead of function.

Has been truncated to: _12345678910111213141516.īe ware that the variables names are stores in the same space with function names. The length of the variable name is limited to 24 characters. * The percent character can only be used as first character in the variable name

In order to define a variable, in the Scilab console type: „variable name” = „value” and press : ->variable_name = 12 I prefer to call them variables maybe because the term “variables” is used in other programming languages like C or Python. So in other tutorials, books, you’ll find “objects” instead of “variables”. From the variables point of view Scilab is very flexible, similar to Matlab®. Every Scilab script, function or routine that we need to write will contain for sure variables.
