Matrix Operations: dspmtrx3
Matrix Operations: dspmtrx3
>>dspmtrx3
Matrix Sum/Subtract
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
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
^ Matrix power
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
>> x = 0:0.1:5;
Page 8
Display Format for Numeric Values
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.
3. Plot a given data set or the results of computation is possible with very few
commands. x = 0:𝜋/100:2*𝜋.
Page 10