0% found this document useful (0 votes)
2 views

Question 5

The document presents MATLAB code that performs various matrix operations on two defined matrices A and B, including addition, subtraction, multiplication, and element-wise multiplication. It also calculates the transpose and determinant of matrix A. The results of these operations are displayed in the MATLAB environment.

Uploaded by

Sauvik Arya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Question 5

The document presents MATLAB code that performs various matrix operations on two defined matrices A and B, including addition, subtraction, multiplication, and element-wise multiplication. It also calculates the transpose and determinant of matrix A. The results of these operations are displayed in the MATLAB environment.

Uploaded by

Sauvik Arya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

% Name: Sauvik Arya

% Roll No: 10
% Question 5
clc;

% Defining matrices A and B


A = [1 2 3; 4 5 6; 7 8 9];
B = [2 4 6; 1 3 5; 7 8 9];

% Matrix addition and subtraction


Addition_Mat = A + B;
Subtraction_Mat = A - B;

% Matrix multiplication (A * B)
Multiplication_Mat = A * B;

% Element-Wise multiplication (A .* B)
ElementWiseMultiplication_Mat = A .* B;

% Transpose of matrix A
Transpose_AMat = A';

% Determinant of A
Determinant_AMat = det(A);

% Displaying results
disp('Matrix A:');
disp(A);

disp('Matrix B:');
disp(B);

disp('Matrix Addition (A + B):');


disp(Addition_Mat);

disp('Matrix Subtraction (A - B):');


disp(Subtraction_Mat);

disp('Matrix Multiplication (A * B):');


disp(Multiplication_Mat);

disp('Element-wise Multiplication (A .* B):');


disp(ElementWiseMultiplication_Mat);

disp('Transpose of Matrix A:');


disp(Transpose_AMat);

disp(['Determinant of Matrix A: ', num2str(Determinant_AMat)]);

Matrix A:
1 2 3
4 5 6
7 8 9

1
Matrix B:
2 4 6
1 3 5
7 8 9

Matrix Addition (A + B):


3 6 9
5 8 11
14 16 18

Matrix Subtraction (A - B):


-1 -2 -3
3 2 1
0 0 0

Matrix Multiplication (A * B):


25 34 43
55 79 103
85 124 163

Element-wise Multiplication (A .* B):


2 8 18
4 15 30
49 64 81

Transpose of Matrix A:
1 4 7
2 5 8
3 6 9

Determinant of Matrix A: 6.6613e-16

Published with MATLAB® R2024b

You might also like