0% found this document useful (0 votes)
50 views11 pages

HW #1 1-DIARY of Matlab Commands

The document contains a diary of MATLAB commands and outputs for various operations on vectors and matrices, including: 1) Defining vectors, finding transpose and size, plotting vectors 2) Calculating matrix multiplication, inverse, and determinant 3) Solving systems of linear equations and finding eigenvalues

Uploaded by

Anjum Iqbal
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)
50 views11 pages

HW #1 1-DIARY of Matlab Commands

The document contains a diary of MATLAB commands and outputs for various operations on vectors and matrices, including: 1) Defining vectors, finding transpose and size, plotting vectors 2) Calculating matrix multiplication, inverse, and determinant 3) Solving systems of linear equations and finding eigenvalues

Uploaded by

Anjum Iqbal
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/ 11

HW #1

1-DIARY of matlab commands

x=[1,3,5,7,9,11]

x =

1 3 5 7 9 11

x=1:2:11

x =

1 3 5 7 9 11

y=x'

y =

1
3
5
7
9
11

x=[1;3;5;7;9;11]

x =

1
3
5
7
9
11

x=x'

x =

1 3 5 7 9 11

z=5:5:30

z =

5 10 15 20 25 30
z(3)

ans =

15

size(x)

ans =

1 6

length(x)

ans =

ans =

0.0000 + 1.0000i

ans =

0.0000 + 1.0000i

sqrt(-3)

ans =

0.0000 + 1.7321i

a=[sqrt(4),1;sqrt(-4),-5]

a =

2.0000 + 0.0000i 1.0000 + 0.0000i


0.0000 + 2.0000i -5.0000 + 0.0000i

b=[1 2 3;4 5 6]

b =

1 2 3
4 5 6

diary off
c=a*b

c =

6.0000 + 0.0000i 9.0000 + 0.0000i 12.0000 + 0.0000i


-20.0000 + 2.0000i -25.0000 + 4.0000i -30.0000 + 6.0000i

d=c.*b

d =

1.0e+02 *

0.0600 + 0.0000i 0.1800 + 0.0000i 0.3600 + 0.0000i


-0.8000 + 0.0800i -1.2500 + 0.2000i -1.8000 + 0.3600i

e=b./c

e =

0.1667 + 0.0000i 0.2222 + 0.0000i 0.2500 + 0.0000i


-0.1980 - 0.0198i -0.1950 - 0.0312i -0.1923 - 0.0385i

f=a^2

f =

4.0000 + 2.0000i -3.0000 + 0.0000i


0.0000 - 6.0000i 25.0000 + 2.0000i

g=expm(a)

g =

7.2232 + 1.8019i 1.0380 + 0.2151i


-0.4302 + 2.0760i -0.0429 + 0.2962i

plot(x,z)
plot(x,z,+)
plot(x,z,+)

plot(x,z,'+')
plot(t,y)

v=[x',z']

v =

1 5
3 10
5 15
7 20
9 25
11 30

v=[:,2]
v=[:,2]

v=(:,2)
v=(:,2)
_
v(:,2)

ans =

5
10
15
20
25
30

diary off
2
Problem 1-3

Matlab code

x=[3;1;7]; %given vector


y=x'; % X^t transpose of vector
z=y*x; % x*x^t
w=sqrt(z); % finding 2nd norm

output
Problem 4
Matlab code

A=[3 2;1 0];


B=[7 6 8;9 5 4];
C=A*B;
D=B'*A;
w=inv(A); % storing A inverse in w
E=w*B;

Output
Problem 5
1 1
𝐴=[ ]
2 −1
1 1
𝑦=[ ]𝑥
2 −1

𝐴−1 𝑦 = 𝑥

1
𝑎𝑑𝑗𝐴 (𝑦) = 𝑥
|𝐴|
𝑦1
𝑦 = [𝑦 ]
2

0.333 0.333
𝐴−1 = [ ]
0.6667 −0.333
𝑥1 0.333 0.333 𝑦1
[𝑥 ] = [ ][ ]
2 0.6667 −0.333 𝑦2

𝑥1 = 0.333𝑦1 +0.333𝑦2

𝑥2 = 0.6667𝑦1 −0.333𝑦2
Problem 6

Matlab code
A=[1 0 0 2;1 2 0 6;1 3 1 8;0 0 0 8];
b=det(A);

output
Problem #7
𝑎11 𝑎12 𝑎13
𝐴 = [𝑎21 𝑎22 𝑎23 ]
𝑎31 𝑎32 𝑎33

𝒅𝒆𝒕(𝐼λ − A) =?

1 0 0
𝑰 = [0 1 0]
0 0 1
λ 0 0
𝐼λ = [0 λ 0 ]
0 0 λ

λ 0 0 𝑎11 𝑎12 𝑎13


𝐼λ − A = [0 𝑎
λ 0 ] − [ 21 𝑎22 𝑎23 ]
0 0 λ 𝑎31 𝑎32 𝑎33

λ − 𝑎11 −𝑎12 −𝑎13


𝐼λ − A = [ −𝑎21 λ − 𝑎22 −𝑎23 ]
−𝑎31 −𝑎32 λ − 𝑎33

λ − 𝑎11 −𝑎12 −𝑎13


𝒅𝒆𝒕(𝐼λ − A) = | −𝑎21 λ − 𝑎22 −𝑎23 |
−𝑎31 −𝑎32 λ − 𝑎33

λ − 𝑎22 −𝑎23 −𝑎21 −𝑎23 −𝑎21 λ − 𝑎22


𝒅𝒆𝒕(𝐼λ − A) = (λ − 𝑎11 ) | | − (−𝑎12 ) |−𝑎 λ − 𝑎33 | + (−𝑎13 ) |−𝑎31 |
−𝑎32 λ − 𝑎33 31 −𝑎32

𝒅𝒆𝒕(𝐼λ − A) = (λ − 𝑎11 )((λ − 𝑎22 )(λ − 𝑎33 ) − (−𝑎23 )(−𝑎32 ))

+(𝑎12 )(-(𝑎21 )( λ − 𝑎33)-( 𝑎23 )(𝑎31 ))

- (𝑎13 )( 𝑎21 𝑎32 + (𝑎31 )(λ − 𝑎22 ))

𝒅𝒆𝒕(𝐼λ − A) = λ3 − λ2 (𝑎11 +𝑎22 + 𝑎33 ) + λ(𝑎22 𝑎33 − 𝑎23 𝑎32 + 𝑎11 𝑎33 + 𝑎11 𝑎22 − 𝑎12 𝑎21 − 𝑎13 𝑎31 )
− 𝑎11 𝑎22 𝑎33 + 𝑎11 𝑎23 𝑎32 + 𝑎12 𝑎21 𝑎33 − 𝑎12 𝑎23 𝑎21 − 𝑎13 𝑎21 𝑎32 + 𝑎13 𝑎31 𝑎22

Xtic equation

λ3 − λ2 (𝑎11 +𝑎22 + 𝑎33 ) + λ(𝑎22 𝑎33 − 𝑎23 𝑎32 + 𝑎11 𝑎33 + 𝑎11 𝑎22 − 𝑎12 𝑎21 − 𝑎13 𝑎31 ) − 𝑎11 𝑎22 𝑎33
+ 𝑎11 𝑎23 𝑎32 + 𝑎12 𝑎21 𝑎33 − 𝑎12 𝑎23 𝑎21 − 𝑎13 𝑎21 𝑎32 + 𝑎13 𝑎31 𝑎22=0
Problem 8a

Matlab code
A=[-1 2;1 -3];
b=det(A);
c=rank(A);
[v,d]=eig(A);

Output
Problem 8b

Matlab code
B=[-1 2;1 -2];
b=det(B);
c=rank(B);
[v,d]=eig(B);

Output

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