Вы находитесь на странице: 1из 14

MatLab Exercise

Name: Alcoriza, Adrien Raye P. Course: BSEcE

Discrete-Time Signals in the Time-Domain

Chapter 1

Questions:
Q1.1 Run Program P1-1 to generate the unit sample sequence u[n] and display it.

Figure: Answers\q1.fig

Q1.2 What are the purposes of the commands clf, axis, title, xlabel, and ylabel?

clf -clears the figure

axis -controls axis scaling and appearance

title -adds title to a graph

xlabel -adds a label to the x-axis

ylabel -dds a label to the y-axis

Q1.3 Modify Program P1-1 to generate a delayed unit sample sequence ud[n] with a

delay of 11 samples. Run the modified program and display the sequence generated.

Figure: Answers\q1.3.fig
Q1.4 Modify Program P1-1 to generate a unit step sequence s[n]. Run the modified

program and display the sequence generated.

Figure: Answers\q1.4.fig

Q1.5 Modify Program P1-1 to generate a unit step sequence sd[n] with an advance

of 7 samples. Run the modified program and display the sequence generated.

Figure: Answers\q1.5.fig
1.5 Generation of Sequences

Q1.6Run Program P1-2 and generate the complex-valued exponential sequence.

Answers\q1.6.fig

Q1.7 Which parameter controls the rate of growth or decay of this sequence? Which

parameter controls the amplitude of this sequence?

The one controlling the rate of growth or decay is - c on the real side

The one controlling the amplitude is - K

Q1.8 What will happen if the parameter c is changed to (1/12) + (pi/6) *i?

The signal’s envelope will grow with n rather than decay with n.

Q1.9What are the purposes of the operators real and imag?

‘real’ is to take the real part of a Matlab vector.

‘imag’ is to take the imaginary part of a Matlab vector.

Q1.10What is the purpose of the command subplot?

‘subplot’ is to plot more than one graph for the same Matlab figure.
Q1.11 Run Program P1-3 and generate the real-valued exponential sequence.

Answers\q1.11.fig

Q1.12Which parameter controls the rate of growth or decay of this sequence? -a

Which parameter controls the amplitude of this sequence? -K

Q1.13What is the difference between the arithmetic operators ^ and .^?

-“^” raises a square matrix to a power using matrix multiplication.

-“.^” raises the elements of a matrix or vector to a power.

Q1.14 What will happen if the parameter a is less than 1? Run Program Pl.3 again with

the parameter a changed to 0.9 and the parameter K changed to 20.

Answers\q1.14.fig
Q1.15 What is the length of this sequence and how can it be changed?

-it is 36 including zero & it can be changed by the ‘n’ variable.

Q1.16 You can use the MATLAB command sum (s. *s) to compute the energy of a real

sequence s[n] stored as a vector s. Evaluate the energy of the real-valued exponential

sequences x [n] generated in Questions Q1.11 and Q1.14.

E1= 4.5673e+004

E2= 2.1042e+003

Project 1.3 Sinusoidal Sequences

Q1.17 Run Program P1 4 to generate the sinusoidal sequence and display it.

Answers\q1.17.fig

Q1.18 What is the frequency of this sequence and how can it be changed?

f = 0.1 cycles/sample.

By changing the value of ‘f’ we can change it.

Which parameter controls the phase of this sequence? phase

Which parameter controls the amplitude of this sequence? A

What is the period of this sequence? 10

Q1.19What is the length of this sequence and how can it be changed?

-41

-It can be changed by using ‘n’ and changing it’s value.


Q1.20Compute the average power of the generated sinusoidal sequence.

-By using the formula‘sum(x(1:10).*x(1:10))/10’ = 1.1250

Q1.21What are the purposes of the axis and grid commands?

-‘axis’ sets the range of the x-axis and y-axis .

-‘grid’ turns on the grid lines of the graph.

Q1.22 Modify Program P1-4 to generate a sinusoidal sequence of frequency 0.9 and

display it. Compare this new sequence with the one generated in Question Q1.17.

Answers\q1.22.fig

The two graphs are the same.

Now,modify Program P1-4 to generate a sinusoidal sequence of frequency 1.1 and display it

Compare this new sequence with the one generated in Question Q1.17. Comment on your

results.Answers\q1.22-2.fig

The graph here is also identical to the one in Q1.17


Q1.23 Modify the above program to generate a sinusoidal sequence of length 50, frequency
0.08, amplitude 2.5, and phase shift 90 degrees and display it. What is the period of this
sequence?

Answers\q1.23code.txt

-The period is 25.

Q1.24 Replace the stem command in Program P14 with the plot command and run

the program again. What is the difference between the new plot and the one generated in

Question Q1.17?

Answers\q1.24.fig

–the “plot” command connects the points with straight line segments, which
approximates the graph of a continuous-time cosine signal.
Q1.25Replace the stem command in Program P1-4 with the stairs command and run

the program again. What is the difference between the new plot and those generated in

Questions Q1.17 and Q1.24?

Answers\q1.25.fig

the “stairs” command produces a stairs-step plot.

Project 1.4 Random signals

Questions:

Q1.26Write a MATLAB program to generate and display a random signal of length 100

whose elements are uniformly distributed in the interval -2,2.

Answers\q1.26.fig
Q1.27Write a MATLAB program to generate and display a Gaussian random signal of

length 75 whose elements are normally distributed with zero mean and a variance of 3.

Answers\q1.27.fig

Q1.28 Write a MATLAB program to generate and display five sample sequences ot a random
sinusoidal signal of length 31 {Xn]} = {A cos(wn +o)}, where the amplitude A and the phase o
are statistically independent random variables with uniform probability distribution in the range
0<A<4 for the amplitude and in the range 0< o <2pi for the phase.

Answers\q1.28.fig

Answers\q1.28-2.fig
Answers\q1.28-3.fig

Answers\q1.28-4.fig

Answers\q1.28-5.fig
Project 1.5 Signal Smoothing

Q1.29 Run Program1-5 and generate all pertinent signals.

Q1.30What is the form of the uncorrupted signal s [n]? What is the form of the additive

noise d [n]?

s [n]- product of a linear growth with a slowly decaying real exponential.

d [n]- a random sequence distributed from -0.4 up to +0.4.

Q1.31 Can you use the statement x = s + d to generate the noise-corrupted signal? If

not, why not?

-It can’t be used because d is a column vector, whereas s is a row vector one of these
vectors must be transposed before adding.

Q1.32What are the relations between the signals x1, x2, and x3, and the signal x?

-all three signals x1, x2, and x3 are extended versions of x, with an additional sample
added at the left and another additional sample to the right.

Q1.33What is the purpose of the legend command?

-to display a legend for the graphs.


Project 1.6

Q1.34 Run Program P16 and generate the amplitude modulated signal y [n] for various

values of the frequencies of the carrier signal xH [n] and the modulating signal xL [n], and

various values of the modulation index m.

Answers\q1.34.fig

m=0.4

fH=0.1

fL=0.01

Answers\q1.34-2.fig

m=0.9

fH=0.1

fL=0.01

Answers\q1.34-3.fig

m=0.4

fH=0.1

fL=0.005
Q1.35 What is the difference between the arithmetic operators * and .*?

-’*’ multiplies two matrices or vectors using matrix multiplication.

-’.*’ takes the products of the elements of two matrices or vectors that have the same
dimensions.

Program 1-7

Q1.36 Run Program P1-7 and generate the swept-frequency sinusoidal sequence x [n].

Answers\q1.36.fig

Q1.37 What are the minimum and maximum frequencies of this signal?

-minimum occurs at n=0

-maximum occurs at n=100

Q1.38 How can you modify the above program to generate a swept sinusoidal signal with

a minimum frequency of 0. 1 and a maximum frequency of 0.3?

-at n=0, 2a(0) + b = pi/5

-at n=100, 2a(100) + pi/5 = 3pi/5

1.7 Workspace Information

Ql.39 Type who in the Command window. What information is displayed in the command
window as a result of this command?

-the names of the variables defined in the current workspace.

Ql.40 Type whos in the Command window. What information is displayed in the command
window as a result of this command?

-the variables defined in the current workspace, the variable names, their size, the
number of bytes of storage required for each variable, and the data type of each
variable.
1.8 Other types of signals

Q1.41 Write MATLAB programs to generate the square-wave and the sawtooth wave
sequences of the types shown in Fig 1.1 and 1.2. Using these programs, generate and plot the
sequences.

Answers\q1.41.fig Answers\q1.41b.fig

Answers\q1.41c.fig Answers\q1.41d.fig

Вам также может понравиться