- •Міністерство освіти і науки, молоді та спорту україни
- •Laboratory Works of Computing and Programming
- •Contents
- •1.2 Base Concepts of Operating Systems
- •1.3 Linux (lubuntu) Operating System
- •1.4 Tasks for Independent Work
- •1.5 Test Questions
- •2 Laboratory work № 2 Word Processor libreoffice.Writer
- •2.1 What Word Processors Can Do
- •2.2 Tasks for Independent Work
- •2.3 Test Questions
- •3 Laboratory work № 3
- •Introduction to the calc spreadsheet
- •3.1 The Basic Opportunities of Spreadsheets
- •3.1.1 Calc’s Environment
- •3.1.2 Calculations in Calc. Creating and Coping Formulas
- •3.2 The Calc charting capability
- •3.3 Tasks for Independent Work
- •4.2 Main Rules of Works in Scilab System
- •Variables
- •Input of vectors (arrays)
- •Input of matrixes
- •Some operations with matrixes with use of the operator ":"
- •Input from keyboard
- •Operators. Expressions use familiar arithmetic operators and precedence rules.
- •Intrinsic scilab Functions
- •Examples of Expressions
- •4.3 Individual Tasks for Laboratory Work
- •4.4 The Tasks for Self-Examination
- •4.5 Test Questions
- •5 Laboratory work № 5
- •5.3.1The plot function
- •5.3.3 Preparing Graphs for Presentation
- •Interactive Plot Editing
- •5.3.4 3D Plotting
- •5.4 Individual Tasks
- •5.6 Test Questions
- •6 Laboratory work № 6 programming in Scilab
- •6.1 Programming in scilab
- •What Happens When You Call a Function
- •Clearing Functions from Memory
- •6.2 Tasks for laboratory work
- •6.3 Example of performance of the laboratory work
- •6.4 Test Questions
- •7 ReferencEs
Input of vectors (arrays)
Row vectors can be declared using brackets:
>> row_v = [0 1 2]
row_v =0 1 2
To declare column vectors, we use semi-colon at the end of each line:
>> col_v = [0;1;2]
col_v =0
1
2
It is also possible to transpose vectors using the apostrophe (asterisk):
>> col_v = row_v’
col_v =0
1
2
>> row_v = col_v’
row_v = 0 1 2
The colon (:) command easily built the vector. To build an array x of x-values starting at x = 0, ending at x = 1, and having a step size of h =0.1 type this:
>> x=0:0.1:1
The colon is the incremental operator in SCILAB (with default value set to 1):
>> row_v2 = [0:5] // using default increment
row_v2 = 0 1 2 3 4 5
>> row_v3 = [0:0.2:1] // using a different increment
row_v3 = 0.2000 0.4000 0.6000 0.8000 1.0000
Row vectors can be declared using function
linspace(start_value,end_value,amount_of_values)
-->linspace(1,5,9)
ans = 1.000 1.500 2.000 2.500 3.000 3.500 4.0000 4.5000 5.0000
Input of matrixes
A(i, j) - an element i-line and j-column.
A(k) - k-element of the table extended in a column.
Indexes (i, j) always begin with 1.
Matrices are defined by entering the elements row by row. Command
>>M = [1 2 4; 3 6 8];
creates the matrix M = [1 2 4
3 6 8].
There are a number of special matrices that can be defined:
null matrix: M = [];
n-by-m matrix of zeros: M = zeros(n,m);
n-by-m matrix of ones: M = ones(n,m);
n-by-n identity matrix: M = eye(n).
Examples:

A particular element of a matrix can be assigned:
--> M(1,2) = 5;
places the number 5 in the first row, second column.
The colon by itself refers to all the elements of the j-th column of A.
--> b=M(1,:)
b=1 2 4
Some operations with matrixes with use of the operator ":"
|
А(:, j) |
refers to all the elements of the j-th column of A |
|
А(:, j:k) |
refers to the all elements from j to k columns of А |
|
А(і,:) |
refers to all the elements from i-row of matrix A |
|
А(i:k,:) |
refers to the all elements from i to k rows of matrix A |
|
А(:) |
refers to all the elements of a matrix A |
Function size returns Size of array.

The function length() is related to size(). For a matrix with numeric elements length() returns the number of elements.
|
Concatenation is the process of joining small matrices to make bigger ones. In fact, even the simplest matrix is formed by concatenating its individual elements. The pair of square brackets, [], is the concatenation operator. In this example a 4x4 matrix has been created by concatenating four 2x2 matrices.
|
|
Input from keyboard
To have a script request and assign a value to the variable N from the keyboard use
N=input(“ Enter a value for N - “)
You can enter only a single number, like 2.7, then N will be a scalar variable. The load function reads binary files containing matrices generated by earlier SCILAB sessions.
Execute the following commands:
A=[1,2;3,4] A=[1;2,3;4] А(2,2) А(3) А(5) size(A)
А(3,4)=10 size(A) А(5)=6 size(A) А(22)=3 A=A(:) А(22)=3
size(A) [m,n]=size(A)
A=reshape(1:24,4,6) size(A)
А([1,end],:)=[ ] А(:,[1,end])=[ ] size(A)

