Umal-qura university


Defining Matrices In Matlab



Yüklə 0,73 Mb.
səhifə6/30
tarix23.12.2023
ölçüsü0,73 Mb.
#156716
1   2   3   4   5   6   7   8   9   ...   30
Signal and Systems Manual - v2full

Defining Matrices In Matlab

MATLAB is designed to make definition of matrices and matrix manipulation as simple as possible.


Matrices can be introduced into MATLAB in several different ways. For example, either of the statements


>> A = [1 2 3; 4 5 6; 7 8 9];
and
>> A = [ 1 2 3
4 5 6
7 8 9]
creates the obvious 3‐by‐3 matrix and assigns it to a variable A.
Note that:

  • The elements within a row of a matrix may be separated by commas as well as a blank.

  • The elements of a matrix being entered are enclosed by brackets;

  • A matrix is entered in "row‐major order" [i.e. all of the first row, then all of the second

row, etc];

  • Rows are separated by a semicolon [or a newline], and the elements of the row may be separated by either a comma or a space. [Caution: Watch out for extra spaces!]

The matrix element located in the ith row and jth column of A is referred to in the usual way: >> A(1,2), A(2,3)


ans =
2
ans =
6
It's very easy to modify matrices:
>> A(2,3) = 10;



      1. Building Matrices from a Block

Large matrices can be assembled from smaller matrix blocks. For example, with matrix A in hand, we can enter the following commands:


>> C = [A; 10 11 12]; <== generates a (4x3) matrix
>> D = [A; A; A]; <== generates a (9x3) matrix
>> E = [A, A, A]; <== generates a (3x9) matrix
As with variables, use of a semicolon with matrices suppresses output. This feature can be especially useful when large matrices are being generated.



      1. Built-in matrix functions

MATLAB has many types of matrices which are built into its system. For example,





Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   30




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə