When
comparing Scilab with C++, we will find that matrices in Scilab are equivalent
to arrays in C++ and lists in Scilab are equivalent to structures in C++.
Lists (data structures) are preferable when creating a database or when a set
of data has no specified layout. The following points are some differences
between matrices and lists in Scilab:
§
Matrix elements must be all of the same type
(.i.e. matrix of strings, sparse matrix, polynomial matrix, real matrix, ... )
, while the list can store different types of elements like numbers, strings,
matrices, sparse matrices, polynomial, functions, ... and for this reason lists
(typed lists) are implemented in graphic window properties, axes properties, entity
properties, and ... etc. in Scilab as it contains mixed types of data, like the
following:
Figure property
|
Type
|
Type No.
|
Children |
Matrix of graphic handles |
9 |
Figure position |
Real row vector of
size 1 x 2 |
1 |
Figure size |
Real row vector of
size 1 x 2 |
1 |
Axes size |
Real row vector of
size 1 x 2 |
1 |
Auto resize |
Matrix of character
strings |
10 |
View port |
Real row vector of
size 1 x 2 |
1 |
Figure name |
Matrix of character
strings |
10 |
Figure ID |
Real matrix |
1 |
Info message |
Matrix of character
strings |
10 |
Color map |
Matrix of size M x 3,
where M is number of colors and 3 is the RGB channels |
1 |
Pixel map |
Matrix of character
strings |
10 |
Pixel drawing mode |
Matrix of character
strings |
10 |
. . . |
. . . |
. . . |
For
example, you can use lists to create a data base for employees and this data
base contains the following data:
□ Employee name
(string)
□ Employee age
(real matrix)
□ Employee salary
(real matrix)
□ Employee is
married or not (Boolean)
□ Employee notes
(empty in case there are no notes)
§
Number of elements in each row in a matrix is the same,
while in lists each row (entry) can has different number of elements
§
Matrix can't store an empty row while list can do
No comments:
Post a Comment