Scilab Solving Linear Equations Example (linsolve)

equation set:



Scilab solve code:

-->A = [1 -3 -2 -1; 3 -8 1 5; -2 1 -4 1; -1 4 -1 -3]
-->b = [-6; 0; 12; -2]
-->linsolve(A, b)


Notice,

  1. The way to define a matrix in Scilab, the rows are separated by semicolons, but the elements in a row are separated by spaces
  2. matrix b, the result of shifting the constant column to the left of the equal sign
  3. function name linsolveinstead of linesolve

The actual output of executing the above code is as follows:

-->A = [1 -3 -2 -1; 3 -8 1 5; -2 1 -4 1; -1 4 -1 -3]
 A  =
 
    1.  - 3.  - 2.  - 1. 
    3.  - 8.    1.    5. 
  - 2.    1.  - 4.    1. 
  - 1.    4.  - 1.  - 3. 
 
-->b = [-6; 0; 12; -2]
 b  =
 
  - 6.  
    0.  
    12. 
  - 2.  
 
-->linsolve(A, b)
 ans  =
 
    2. 
  - 1. 
    1. 
  - 3.  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325292884&siteId=291194637