Signal Lab Report 1
Signal Lab Report 1
Signal Lab Report 1
a. var = [1 2 3 4 5]
Row vector
b. var = [100]
Scalar
c. var = [10 : 10 : 50]
Row vector
d. var = [10:15]
Row vector
e. var = [ 5 : -1 : 1]
Row vector
f. var = [1 ; 2 ; 3]
Column vector
g. var = [0 -1; 2 4]
Matrix
h. var = [1 2 3 4 5]’
Column
c. Now concatenate ones such that the number of columns in array1 are increased by
2, ( i.e., says array3 = [ ones(1,2), array2 ] ). Can you add array1 and array3? Give
reason to your answer.
Yes because size of two arrays is same.
d. Multiply array1 and array2 without the element-by-element operator (“.”).
Write the error prompted as well as the reason for the error.
The error is Incorrect dimensions for matrix multiplication.
e. Multiply array1 and the transpose of array2 (i.e array 1 * array2’) as in part d.
Explain your findings?
gives error because the size of two vectors is not same.
f. Repeat the same with the expression given by array2’ * array1. What are the
dimensions of your output now?
The dimensions of output vector are 12, 10
b. Take any function from the functions in Table IL 1, use the following functions
given by Table IL 2 on the outputs and write down the results in the following table.
e.g.,
a. Write the syntax for the plot() function and brief description. (use MATLAB help: type “help
plot”
in the command window and then click doc plot).
c. What error did you encounter? Please write the error displayed by MATLAB in your
command
window.
Error using plot Vectors must be the same length
D : Define a new variable Fs = 8000;, where Fs is the sampling frequency, write the following
code and listen to the sound. See the expression for plot and the dimension of the variables.
What happens
when we only use the plot command as plot(t, , ‘b-’)? How many cycles of the signals can you see
in
the figure?
12 cycles of signals can be seen in figure.
A. Add the matrix A with another 5 × 5 matrix created using the rand() function.
B. Multiply the matrix A by 2
D. Multiply the matrix with a diagonal matrix. (construct the diagonal matrix manually)
F. Multiply this matrix by itself to get A2. The find the maximum value of the matrix
using the max() function.
I. Replace the numbers on the locations (2:3,3) and (4,3:5) with zeros.
2. Evaluate the following expressions in MATLAB and give the length of time, ‘t’ and output, ‘x’
vectors. Plot the signals as well. (t=startvalue: 0.05: endvalue;)
a. x(t) = 2cos(10𝜋𝑡) ∀ 𝑡 ∈ [0,5]
3. What is the purpose of the following built-in MATLAB functions and special variables; give
concise answers include format of the functions and an example as well. (Use mathworks
website
or MATLAB help)
abs(), real(), conj(), diag(), size(), inv(), max(), atan(), sound(), soundsc(), audioread(),
audiowrite(), NaN, Inf/inf, mod(), ceil(), rand(), plot()
real():
real Complex real part.
real(X) is the real part of X.
See I or J to enter complex numbers.
Size():
size Size of array.
Inv():
Inverse of array or matrix
Max():
Find maximum value of array or matrix
Atan():
atan Inverse tangent, result in radians.
atan(X) is the arctangent of the elements of X.
sound():
sound Play vector as sound.
Audioread():
audioread Read audio files
audiowrite():
NaN:
NaN Not-a-Number.
NaN is the IEEE arithmetic representation for Not-a-Number.
A NaN is obtained as a result of mathematically undefined
operations like 0.0/0.0 and inf-inf.
Inf:
inf Infinity.
inf returns the IEEE arithmetic representation for positive
infinity. Infinity is also produced by operations like dividing by
zero, eg. 1.0/0.0, or from overflow, eg. exp(1000).
Mod():
mod Modulus after division.
Ceil():
ceil Round towards plus infinity.
ceil(X) rounds the elements of X to the nearest integers
towards infinity.
Rand():
rand Uniformly distributed pseudorandom numbers.
R = rand(N) returns an N-by-N matrix containing pseudorandom
values.
Plot():
plot Linear plot.
plot(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, disconnected
line objects are created and plotted as discrete points vertically at
X.