Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Lab_MATLAB_English_Part2.doc
Скачиваний:
2
Добавлен:
19.11.2019
Размер:
421.89 Кб
Скачать

3 Laboratory work № 3 The Work with Matrixes in matlab

3.1 Multidimensional Arrays

Sometimes you need to keep track of related information in an array. For example, to keep track of each pixel on your computer screen, you need to refer to its X and Y coordinates. This can be done using a multidimensional array to store the values.

Some elementary matrix functions and operations of transformation and decomposition

expm - Matrix exponential

Logm - Matrix logarithm

sqrtm - Matrix square root

norm - Matrix or vector norm

rank - Matrix rank

det - Determinant

trace - Sum of diagonal elements

inv - Matrix inverse

size - Size of array

reshape(x,m,n) - returns the m-by-n matrix whose elements are taken columnwise from x.

length - Length of vector

diag - Diagonal matrices

triu - Extract upper triangular part

tril - Extract lower triangular part

Execute the following commands:

A=reshape(1:24,4,6) triu(A) triu(A,0) triu(A,2) triu(А, -1) tril(A)

v=1:5 diag(v) diag(v,2) diag(v, -1)

diag(A) diag(A,2) diag(А, -1)

A=reshape(1:24,4,6) rot90(A) rot90(A,2)

The basic matrix operations :

А'

- transposing of a matrix

А+В

- addition (subtraction) of matrixes

А*В

- multiplication of matrixes

А/В

- the right division of matrixes

А\В

- the left division of matrixes

А^р

- exponentiation of a matrix

А.*В

- on element multiplication of matrixes

А.

- on element division of matrixes

А.

- on element exponentation of matrixes

Execute the following commands:

m=3;n=4; a=rand(m,n) b=rand(m,n) c=rand(1,n)

p1=a*b p2=a.*b p3=a*c p4=a.*c

3.2 Tasks for Laboratory Work

Variant 1

1. The integer m,n and matrix A(m,n) are given. Find rows in which there are more than three elements which are equal to zero.

2. The integer n and square matrix A(n,n) are given. Count up the average value of elements which are the squares of integers and which are located

1) in rows with the first negative elements;

2) in rows with the first positive elements;

3) in rows which begin with 0;

Create on the form the List box control, which allows user to select one or more items of task. (Set property Multiselected=2 Extended). Your program has to perform only selected items.

Variant 2

1. The integer n and square matrix A(n,n) are given. Find rows in which all elements are equal to zero.

2. The integer n and square matrix A(n,n) are given. Count up the sum of elements, which are the squares of integers and which are located

1) higher than side diagonal;

2) below than side diagonal;

3) on the side diagonal.

Create on the form the List box control, which allows user to select one or more items of task. (Set property Multiselected=2 Extended). Your program has to perform only selected items.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]