0% found this document useful (0 votes)
16 views4 pages

%matrices A (1 2 3 4 5 6 7 8 9) A

The document demonstrates operations on matrices in MATLAB such as creating matrices, finding the size and inverse of matrices, multiplying matrices, and calculating the determinant of matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

%matrices A (1 2 3 4 5 6 7 8 9) A

The document demonstrates operations on matrices in MATLAB such as creating matrices, finding the size and inverse of matrices, multiplying matrices, and calculating the determinant of matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

>> %Matrices

>>

>> A = [1 2 3 ; 4 5 6 ; 7 8 9 ]

A=

1 2 3

4 5 6

7 8 9

>> size(A)

ans =

3 3

>> B = A'

B=

1 4 7

2 5 8

3 6 9

>> I = eye(3)

I=

Diagonal Matrix

1 0 0

0 1 0

0 0 1
>> x = [6 2 3 8]

x=

6 2 3 8

>> y = diag(x)

y=

Diagonal Matrix

6 0 0 0

0 2 0 0

0 0 3 0

0 0 0 8

>> diag(A)

ans =

>> R = rand(5,6)

R=

0.784952 0.224715 0.692604 0.810290 0.926639 0.341549

0.912540 0.367897 0.552040 0.023130 0.127646 0.308580

0.152432 0.611016 0.252828 0.955954 0.196639 0.796220


0.015150 0.825161 0.316308 0.933960 0.071323 0.514448

0.843004 0.258667 0.985314 0.168286 0.801886 0.617077

>> C = (2*A)+(2*B)

C=

4 12 20

12 20 28

20 28 36

>> D = B-3

D=

-2 1 4

-1 2 5

0 3 6

>> E = A*B

E=

14 32 50

32 77 122

50 122 194

>> F = A.^2

F=

1 4 9

16 25 36
49 64 81

>> prod(A)

ans =

28 80 162

>> A*B'

ans =

30 36 42

66 81 96

102 126 150

>> det (A)

ans = 6.6613e-16

>> det(B)

ans = 0

>> inv(A)

warning: matrix singular to machine precision, rcond = 1.54198e-18

ans =

-4.5036e+15 9.0072e+15 -4.5036e+15

9.0072e+15 -1.8014e+16 9.0072e+15

-4.5036e+15 9.0072e+15 -4.5036e+15

You might also like