User Tools

Site Tools


software:scilab:linear-algebra

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
software:scilab:linear-algebra [2020/07/28 08:02] – [Matrix] tormecsoftware:scilab:linear-algebra [2023/05/28 16:37] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Linear algebra ======
  
 +===== Vector =====
 +
 +To define a column vector:
 +
 +<code>
 +v = [1; 2; 3]
 +</code>
 +
 +To define a row vector, two syntaxes are possible:
 +
 +<WRAP group>
 +<WRAP half column>
 +<code>
 +v = [1 2 3]
 +</code>
 +</WRAP>
 +
 +<WRAP half column>
 +
 +<code>
 +v = [1, 2, 3]
 +</code>
 +</WRAP>
 +</WRAP>
 +
 +
 +
 +===== Matrix =====
 +
 +To define a matrix:
 +
 +<code>
 +M = [1 2 3; 4 5 6; 7 8 9]
 +</code>
 +
 +$$
 +\begin{bmatrix}
 +1 & 2 & 3 \\ 
 +4 & 5 & 6 \\
 +7 & 8 & 9 \\
 +\end{bmatrix}
 +$$
 +===== Get element from vector/matrix =====
 +
 +Get element from a vector ''v'':
 +  * to get element in the ''<i>''-position: <code>v(<i>)</code>
 +
 +Get element from a matrix ''M'':
 +  * to get the element in the ''<i>''-row and ''<j>''-column: <code>M(<i>,<j>)</code>
 +  * to get the whole ''<i>''-row: <code>M(<i>,:)</code>
 +  * to get the whole ''<j>''-column: <code>M(:,<j>)</code>
 +  * to get the whole ''<j>''-''<k>''-columns: <code>M(:,[<j>,<k>])</code>
 +  * to get the whole ''<i>''-''<k>''-rows: <code>M([<i>,<k>],:)</code>
 +
 +
 +===== Data structure =====
 +
 +The ''struct()'' method allows to save data in the form ''<field>, <value>''.
 +
 +
 +===== Create data structure with a loop =====
 +
 +<code>
 +g = list("g1", "g2", "g3")
 +p = struct()
 +
 +for i = g
 +    p(i) = i
 +end
 +
 +fn = fieldnames(p)
 +for j = fn'
 +    disp(p(j))
 +end
 +</code>
software/scilab/linear-algebra.txt · Last modified: 2023/05/28 16:37 by 127.0.0.1