informationlobi.blogg.se

Matriz scilab
Matriz scilab





matriz scilab
  1. #Matriz scilab how to
  2. #Matriz scilab code

  • extract the elements contained between the row before the last one and the last three columns:Ī synthesis of the variables used in this article can be viewed in the Variable Browser within Scilab.I'm trying to simulate the heat distribution on an infinite plate over time.
  • On the examples below we are going to use the testMatrix variable to: The good thing about it is that we do not have to know the index of the row or column. The $ symbol stands for the last row or the last column in a matrix. In this case we have to input as arguments the start and end index for the row and the start and end index for the column: ->testSubMatrix = testMatrix(2:3,3:4)Īnother way of extracting data from a matrix is by using the $ (dollar) symbol. Let’s say that we have a 3×4 matrix from which we want to extract the values of the last 2 rows and 2 columns. If we need only the first two values of the 3rd column we have to define the start row and the end row: ->testColumn = testMatrix(2:3,3) In the example above we defined a new variable testColumn which contains the values of the 3rd column of the matrix testMatrix. If we want to extract all rows for a particular column we use the colon operator “:” ->testColumn = testMatrix(:,3) testColumn = 3. The difference being that we specify first how many rows we want to extract for a particular column. The same technique applies if we want to extract a column.

    #Matriz scilab code

    This way the code is more simple, compact and robust. If we are interested in all the elements of the columns for a particular row it makes sense to use the colon operator because we don’t have to specify the index for the first and last column. For example if we want to extract only the first 3 columns, corresponding to the 2nd row: ->testRow = testMatrix(2,1:3) testRow = 11.

    matriz scilab

    This method makes sense to use only if we want to extract just a part of the columns, not all of them. Since we know that we have 4 columns, we tell Scilab to extract the values starting with the 1st column up to the 4th column, corresponding to the 2nd row: ->testRow = testMatrix(2,1:4) testRow = 11.

    matriz scilab

    >Īnother method of doing the same extraction is using the explicit definition of the start and end column index. Basically this tells Scilab to extract the values from all the columns corresponding to the second row: ->testRow = testMatrix(2,:) testRow = 11. To do this, as arguments of the matrix we insert the row index, followed by the colon operator. We want to extract the second row from out test matrix and put the values into a new variable named testRow. There are several ways of doing this and we’ll learn a couple of techniques.įirst method of row extraction is using the colon operator “:” Suppose we want to extract a complete row from out test matrix. In the same way we can extract whatever value we want from the matrix just by specifying the index of the row and column. >testElement = testMatrix(2,3) testElement = 13. For example we want to put in a separate variable, named testElement, the value from line 2 and column 3 of the matrix. To extract just one element from a matrix we have to specify from which row and what column we want our value to be extracted. We’ll define a non-square matrix, named testMatrix, with 3 rows and 4 columns just to make this example more generic: ->testMatrix = one column, one row, a sub-matrix).įirst let’s define a matrix which is going to be our test variable.

    #Matriz scilab how to

    In this article we’ll learn how to extract a particular value from a matrix or a particular set of values (e.g. So far we have learned how to define a matrix in Scilab.







    Matriz scilab