0% found this document useful (0 votes)
155 views5 pages

ALCANTARA 1912451 SimulationActivity2.1 MatrixInMATLAB

This document contains a MATLAB activity where the student is asked to: 1) Write the syntax to create 3 matrices 2) Enter the matrices in MATLAB using the given formats 3) Compute mathematical expressions using the matrices and show the MATLAB syntax and output The student provides the correct MATLAB syntax for creating the matrices and entering them. When computing the expressions, some are not possible due to dimensional mismatches between the matrices. The student identifies which expressions are not possible.
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)
155 views5 pages

ALCANTARA 1912451 SimulationActivity2.1 MatrixInMATLAB

This document contains a MATLAB activity where the student is asked to: 1) Write the syntax to create 3 matrices 2) Enter the matrices in MATLAB using the given formats 3) Compute mathematical expressions using the matrices and show the MATLAB syntax and output The student provides the correct MATLAB syntax for creating the matrices and entering them. When computing the expressions, some are not possible due to dimensional mismatches between the matrices. The student identifies which expressions are not possible.
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/ 5

NAME: ALCANTARA, GELVHER C.

Section: CE21S1

MATLAB ACTIVITY 2 – Matrix in MATLAB

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

Matrix MATLAB Syntax

A1 = [ones(2,3) zeros(2,2);eye(3) ones(3,1) zeros(3,1)]

A2 = [pi*ones(1,5);ones(1,5);zeros(1,5);ones(1,5)]

A3 = [sqrt(2)*ones(3)]

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/4;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

MATLAB SYNTAX

B1 = A*C

MATLAB OUTPUT

B1 = 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

MATLAB SYNTAX

B2 = A+C'

MATLAB OUTPUT

B2 = 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

MATLAB SYNTAX

B3 = 6*A'-2*(C*B')

MATLAB OUTPUT

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 element wise
multiplication, use '.*'.

The matrices C and B’ have no product because they don’t have the same inner dimension.
Therefore, the expression in item number three is not possible.
4. Sum of the product of A and its transpose and the product of C and its transpose.

MATLAB SYNTAX

B4 = (A*A')+(C*C')

MATLAB OUTPUT

Matrix dimensions must agree.

The two matrices have no sum because they have different dimensions. Therefore, the expression
in item number four is not possible.

5. Product of A and B

MATLAB SYNTAX

B5 = A*B

MATLAB OUTPUT

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 element wise
multiplication, use '.*'.

The matrices A and B have no product because they don’t have the same inner dimension.
Therefore, the expression in item number five is not possible.

“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