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

Matrix Operations: dspmtrx3

This document provides a summary of common matrix operations and functions in MATLAB including: - Summing, subtracting, multiplying, and dividing matrix elements along rows and columns - Extracting the diagonal of a matrix - Computing the matrix exponential and comparing it to the exponential of each element - Plotting common trigonometric, polar, and 3D surface functions - Demonstrating arithmetic, relational, and common mathematical operators and functions - Using the colon operator to generate numeric vectors - Formatting numeric values for display - Examples of assigning variables and basic calculations

Uploaded by

May Thet Tun
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)
43 views

Matrix Operations: dspmtrx3

This document provides a summary of common matrix operations and functions in MATLAB including: - Summing, subtracting, multiplying, and dividing matrix elements along rows and columns - Extracting the diagonal of a matrix - Computing the matrix exponential and comparing it to the exponential of each element - Plotting common trigonometric, polar, and 3D surface functions - Demonstrating arithmetic, relational, and common mathematical operators and functions - Using the colon operator to generate numeric vectors - Formatting numeric values for display - Examples of assigning variables and basic calculations

Uploaded by

May Thet Tun
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

Matrix Operations

>>dspmtrx3

Matrix Sum/Subtract

 Sum/Subtract matrix elements along rows, columns, or entire input.

Page 1
Page 2
Matrix Multiply/Divide
 Multiply or divide inputs.

>>a*b;

>>a/b;

Page 3
Extract Diagonal
Extract main diagonal of input matrix.

>> diag(a);

Matrix Exponential
Example
This example computes and compares the matrix exponential of A and the exponential of
A.
>>expm(a);

Page 4
sin
Sine of argument in radians

Syntax
Y = sin(x)
Examples:
Graph the sine function over the domain−𝜋 ≤ 𝑥 ≤ 𝜋.
x = -pi:0.01:pi;
plot(x,sin(x)), grid on

Examples
Graph the cosine function over the domain −𝜋 ≤ 𝑥 ≤ 𝜋.
x = -pi:0.01:pi;
plot(x,cos(x)), grid on

Page 5
Polar

Polar coordinate plot.

Examples
Create a simple polar plot using a dashed red line:
t = 0:.01:2*pi;
polar(t,sin(2*t).*cos(2*t),'--r')

Page 6
Peaks
Example function of two variables.

>> peaks

Page 7
Arithmetic Operators

+ Plus Relational Operators

- Minus < Less than

. Decimal point <= Less than or equal to

= Assignment > Greater than

* Matrix multiplication >= Greater than or equal to

/ Matrix right division == Equal to

\ Matrix left division ~= Not equal to

^ Matrix power

' Matrix transpose

.* Array multiplication (element-wise)

./ Array right division (element-wise)

.\ Array left division (element-wise)

.^ Array power (element-wise)

.' Array transpose

Mathematical Functions
>>cos(x) Cosine >> abs(x) Absolute value
>>sin(x) Sine >>angle(x) Phase angle
>>exp(x) Exponential >> conj(x) Complex conjugate
>>sqrt(x) Square root >>log(x) Natural logarithm

Colon operator (:)

>> x = 0:0.1:5;

Page 8
Display Format for Numeric Values

>>x = [4/3 1.2345e-6]


>>x =
1.3333 0.0000

Page 9
Exercises

1. Assign the value of 3 and 4 to the variables x and y respectively, then calculate
the value z where z=2x+3y.

2. Perform the operation 3√6 + 𝑥 for x=10.

3. Plot a given data set or the results of computation is possible with very few
commands. x = 0:𝜋/100:2*𝜋.

Page 10

You might also like