DSP LAB#1 Name: - Section: - Reg #
DSP LAB#1 Name: - Section: - Reg #
LAB#1
Name: __________
Section: _____
Reg #:_______
Q.1 Run the MATLAB help desk by typing helpdesk. The help desk provides a hypertext
interface to the MATLAB documentation.
Q.2 Use MATLAB as a calculator. Try the following:
pi*pi - 10
sin(pi/4)
ans 2 %<--- "ans" holds the last result
Q.5 Make sure that you understand the colon notation. In particular, explain in words
what the following MATLAB code will produce.
jkl = 0 : 6
jkl = 2 : 4 : 17
jkl = 99 : -1 : 88
ttt = 2 : (1/9) : 4
tpi = pi * [ 0:0.1:2 ];
Q.6 Extracting and/or inserting numbers into a vector is very easy to do. Consider the
following definition of xx:
xx = [ zeros(1,3), linspace(0,1,5), ones(1,4) ]
xx(4:6)
size(xx)
length(xx)
xx(2:2:length(xx)
Explain the results echoed from the last four lines of the above code.
Q.7
Now write a statement that will take the vector xx defined in part (b) and replace the even
indexed elements (i.e., xx(2), xx(4), etc) with the constant . Use a vector replacement, not a
loop.
Q.8 Enter the following in MATLAB.
2
A=
6
3
,B=
4
1
6
6
2