0% found this document useful (0 votes)
59 views10 pages

CMHWK4 Matlab

This document contains code to calculate various properties of matrices including: 1) The trace, element-wise multiplication, and transpose multiplication of matrix S. 2) The element-wise multiplication of vector A with matrix S and matrix S with vector A. 3) The element-wise multiplication of matrices S and T with vector A. It also contains code to calculate the eigen values and vectors of matrices a, b, c, and d.
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)
59 views10 pages

CMHWK4 Matlab

This document contains code to calculate various properties of matrices including: 1) The trace, element-wise multiplication, and transpose multiplication of matrix S. 2) The element-wise multiplication of vector A with matrix S and matrix S with vector A. 3) The element-wise multiplication of matrices S and T with vector A. It also contains code to calculate the eigen values and vectors of matrices a, b, c, and d.
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/ 10

9/26/22 10:06 AM HW4.

m 1 of 1

% Storing vector A and Second order tensors S and T


A=[2;-1;4];
S=[-1,0,5;3, 7, 4;9, 8 ,6];
T=[8 -1 6;5 4 9;-7 8 -2];

%(a) tr(S)
Trace_S=trace(S)

%(b) S:S
SS=S.*S

%(c) S:S^T
SST=S.*transpose(S)

%(d)A.S
AS=A.*S

%(e)S.A
SA=S.*A

%(f) S.T.A
STA=S.*T.*A
9/26/22 10:05 AM MATLAB Command Window 1 of 1

>> HW4

Trace_S =

12

SS =

1 0 25
9 49 16
81 64 36

SST =

1 0 45
0 49 32
45 32 36

AS =

-2 0 10
-3 -7 -4
36 32 24

SA =

-2 0 10
-3 -7 -4
36 32 24

STA =

-16 0 60
-15 -28 -36
-252 256 -48

>>
9/26/22 12:15 PM HW4Q4.m 1 of 1

%Program to calculate eigen values


a = [4 -4 0;-4 0 0;0 0 3]
b = [2 -sqrt(3) 0;-sqrt(3) 4 0; 0 0 4]
c = [1 0 0;0 3 -1;0 -1 3]
d = [2 -1 1;-1 0 1;1 1 2]
%where s=eigen values, v=eigen vectors.
%eigen value of a=s1, b=s2, c=s3, d=s4
%eigen vector of a=v1, b=v2, c=v3, d=v4
[v1,s1] = eig(a)
[v2,s2] = eig(b)
[v3,s3] = eig(c)
[v4,s4] = eig(d)
9/26/22 12:15 PM MATLAB Command Window 1 of 2

>> HW4Q4

a =

4 -4 0
-4 0 0
0 0 3

b =

2.0000 -1.7321 0
-1.7321 4.0000 0
0 0 4.0000

c =

1 0 0
0 3 -1
0 -1 3

d =

2 -1 1
-1 0 1
1 1 2

v1 =

-0.5257 0 -0.8507
-0.8507 0 0.5257
0 1.0000 0

s1 =

-2.4721 0 0
0 3.0000 0
0 0 6.4721

v2 =

-0.8660 0 -0.5000
-0.5000 0 0.8660
0 1.0000 0
9/26/22 12:15 PM MATLAB Command Window 2 of 2

s2 =

1 0 0
0 4 0
0 0 5

v3 =

1.0000 0 0
0 -0.7071 -0.7071
0 -0.7071 0.7071

s3 =

1 0 0
0 2 0
0 0 4

v4 =

-0.4082 0.5774 -0.7071


-0.8165 -0.5774 -0.0000
0.4082 -0.5774 -0.7071

s4 =

-1.0000 0 0
0 2.0000 0
0 0 3.0000

>>

You might also like