You are on page 1of 4

NAME: APARTA, IVAN B.

Section: ME12S2

MATLAB ACTIVITY 2 – Matrix in MATLAB

A. Write the syntax that will create the following matrices.

Matrix MATLAB Syntax

[1 1 1 0 0;1 1 1 0 0;1 0 0 1 0;0 1 0 1


0; 0 0 1 1 0]

[pi pi pi pi pi;1 1 1 1 1;0 0 0 0 0;1 1


1 1 1]

[sqrt(2) sqrt(2) sqrt(2); sqrt(2)


sqrt(2) sqrt(2); sqrt(2) sqrt(2)
sqrt(2)]

B. In MATLAB enter the following matrices use appropriate format. Write your syntax
in the space provided.

MATLAB Syntax

Syntax for the format: format rat

Syntax for Matrix A: A=[1 1/2;1/3 ¼; 1/5 1/6]

Syntax for Matrix B: B=[5 -2]

Syntax for Matrix C: C=[4 5/4 9/4; 1 2 3]


Using MATLAB commands and the Matrices in above compute the following
expressions if possible. Write the MATLAB SYNTAX you used and MATLAB out put on
the space provided

1. Product of A and C

>> A*C
ans =
9/2 9/4 15/4
19/12 11/12 3/2

29/30 7/12 19/20

2. Sum of A and transpose of C

>> A+C'
ans =
5 3/2
19/12 9/4
49/20 19/6

3. Six times of transpose of A subtracted to Twice C multiplied to transpose of


B

>> 6*(A'-2*C*B')

Error using *
Incorrect dimensions for matrix multiplication. Check that the number of
columns in the first matrix matches the number of rows in the second matrix. To
perform elementwise multiplication, use '.*'.

4. Sum of the product of A and its transpose and the product of C and its
transpose.

>> A*A'+C*C'

Matrix dimensions must agree.

5. Product of A and B

>> A*B
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the first matrix matches the number of rows in the second matrix. To perform
elementwise multiplication, use '.*'.
Honor Pledge for Graded Assignments
“I affirm that I shall not give or receive any unauthorized help on this
assignment and that all work is my own.”

You might also like