Some basic matrices can be generated with a single command: zeros Notice that expressions like 10:-2:1, 10:-2:0.3 would produce the same result while 11:-2:2 would not. To have non-unit spacing we specify the increment: 10 : -2 : 2 ![]() The expression 1:10 results in a row matrix with elements 1, 2, …, 10, i.e.: 1:10 The colon operator is one of the most important operators in Scilab. The sum of the main diagonal is easily done with the help of the function diag. This is done by entering: sum(M,'c') // column sums Put the whole list of elements in a pair of square brackets.įor example, to enter a 3 x 3 magic square and assign to the variable M : M = įor a magic square, we may wish to check for its column sums and row sums and the sum of diagonals.Separate each row of elements with a semi-colon, and. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |