Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views17 pages

01 Matlab Commands

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 17

Matrices in MATLAB

‫ا

اب‬

١
‫ ا‬
‫    ات )  وف‪...‬أرم‪#  (.....‬‬
‫‪& '  ()*+‬ف وأ‪%‬ة‬
‫ ‪%‬د اف و‪%‬د ا‪%-‬ة ‪ ) ',‬أ‪+‬د ا أو‬
‫‪ /‬ا(‬
‫ و‪ * 3‬ط أ‪%+‬ا ‪,‬وى ‪%‬د اف ‪% 0‬د ا‪%-‬ة‬
‫ ‪ /‬ا ‪5  67‬ل ا‬

‫‪٢‬‬
(1 2 3
456
7 8 9)

٣
Matrices

 To type a matrix into MATLAB you must:


 Begin with a square bracket [.
 Separate elements in a row with commas or
spaces.
 Use a semicolon (;) to separate rows
 End the matrix with another square bracket].
Matrices

 Example
Matrices

 To obtain the size of a specific variable or Matrix use the


command size(A).
 For example
 The result will be a row vector with two entries: the
first is the number of rows and the second is the number of columns
‫ ا<‬
‫  ;& و) ‪:‬ى ‪ & '6‬وا‪ ' %‬أى‬
‫‪%‬د  ا‪%-‬ة‬

‫‪٧‬‬
Vectors

A= [initial value: step: final value]

x= [1: 5]
y =[3: -1: 1]
x =[2: 2: 7]
Matrix operations

 A+B
 A+B+C
 (A+B+C)-10
Matrix generators

 Note: To tell MATLAB how big these matrices should be, you give the
functions the number of rows and columns.
 To convert rows into columns we use the transpose symbol ‘
 The command det(x) finds the determinant of a matrix
 The command inv(x) finds the inverse of a matrix.
Row index and column index

 You can pick out any element of a vector or a matrix, for


example to pick out (to call) the third element of the vector ‘B’
type: B(3)
Row index and column index

 You can pick out the first and the second elements in the vector ‘B’ by
using a vector as an index to ‘B’ Type: B([1 2]).
‫! ر  
ا
 م ا‬
A(row number, :)

‫ د 
ا
 م ا‬# ‫! ر‬
A(:,column number )

Name of matrix(rows , columns)

١٤
Column symbol as an index

You might also like