0% found this document useful (0 votes)
1K views4 pages

Aparta Mes12s2 Mathlab Simulation-Activity-2.1

The document contains MATLAB code and output for matrix operations. It defines three matrices A, B, and C with fractional elements and performs various operations on them including multiplication, addition, transposition, and elementwise operations. Some operations produce errors due to incompatible matrix dimensions.
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)
1K views4 pages

Aparta Mes12s2 Mathlab Simulation-Activity-2.1

The document contains MATLAB code and output for matrix operations. It defines three matrices A, B, and C with fractional elements and performs various operations on them including multiplication, addition, transposition, and elementwise operations. Some operations produce errors due to incompatible matrix dimensions.
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

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