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

Matrix Exp 1

The document shows various MATLAB commands used to create, manipulate, and summarize matrices. It defines two matrices X and Y, performs basic arithmetic operations on them like addition and multiplication, and also shows commands for creating matrices filled with random, sequential, or identical values.

Uploaded by

Ritesh Kaushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

Matrix Exp 1

The document shows various MATLAB commands used to create, manipulate, and summarize matrices. It defines two matrices X and Y, performs basic arithmetic operations on them like addition and multiplication, and also shows commands for creating matrices filled with random, sequential, or identical values.

Uploaded by

Ritesh Kaushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

30/7/19 3:04 PM MATLAB Command Window 1 of 4

>> X=[3,5,6;7,5,2;0,3,5]

X =

3 5 6
7 5 2
0 3 5

>> Y=[5,2,4;7,3,2;5,2,5]

Y =

5 2 4
7 3 2
5 2 5

>> X+Y

ans =

8 7 10
14 8 4
5 5 10

>> X-Y

ans =

-2 3 2
0 2 0
-5 1 0

>> X*Y

ans =

80 33 52
80 33 48
46 19 31

>> X/Y

ans =

-98.0000 19.0000 72.0000


-50.0000 11.0000 36.0000
-80.0000 15.0000 59.0000

>> X\Y

ans =
30/7/19 3:04 PM MATLAB Command Window 2 of 4

-6.7500 -2.8750 -4.7500


13.7500 5.8750 8.7500
-7.2500 -3.1250 -4.2500

>> X./Y

ans =

0.6000 2.5000 1.5000


1.0000 1.6667 1.0000
0 1.5000 1.0000

>> X.*Y

ans =

15 10 24
49 15 4
0 6 25

>> X^5

ans =

76046 96448 94382


88634 112416 110010
38661 49032 47981

>> Y^0-2

ans =

-1 -2 -2
-2 -1 -2
-2 -2 -1

>> X'

ans =

3 7 0
5 5 3
6 2 5

>> Y'

ans =

5 7 5
2 3 2
30/7/19 3:04 PM MATLAB Command Window 3 of 4

4 2 5

>> //creating matrices


//creating matrices

Error: Unexpected MATLAB operator.

>> /creating matrices


/creating matrices

Error: Unexpected MATLAB operator.

>> %creating matrices


>> zeros(3,4)

ans =

0 0 0 0
0 0 0 0
0 0 0 0

>> ones(7,9)

ans =

1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1

>> eye(2,4)

ans =

1 0 0 0
0 1 0 0

>> rand(4,4)

ans =

0.8147 0.6324 0.9575 0.9572


0.9058 0.0975 0.9649 0.4854
0.1270 0.2785 0.1576 0.8003
0.9134 0.5469 0.9706 0.1419

>> randn(4,4)
30/7/19 3:04 PM MATLAB Command Window 4 of 4

ans =

-0.1241 0.6715 0.4889 0.2939


1.4897 -1.2075 1.0347 -0.7873
1.4090 0.7172 0.7269 0.8884
1.4172 1.6302 -0.3034 -1.1471

>> help(rand)
Input is a value of type double.

>> magic(4)

ans =

16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1

>> pascal(5)

ans =

1 1 1 1 1
1 2 3 4 5
1 3 6 10 15
1 4 10 20 35
1 5 15 35 70

>>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy