You are on page 1of 22

Electrical and Electronics Engineering Department

COMPILATION IN SIGNALS,
SPECTRA AND SIGNAL
PROCESSING
ECL301L T41

SUBMITTED TO

ENGR. GILBEYS JHON LADION

Electrical and Electronics Engineering Department

MACHINE PROBLEMS
COMPILATION IN SIGNALS,
SPECTRA AND SIGNAL
PROCESSING
ECL301L T41

SUBMITTED BY

ROQUE, MADEL M.

SUBMITTED TO

ENGR. GILBEYS JHON LADION

Electrical and Electronics Engineering Department

TABLE OF CONTENTS
MACHINE
PROBLEM
NUMBER

1
2
3
4
5
6
7

MACHINE PROBLEM TITLE

SIGNAL PLOT
CONVOLUTION
CORRELATION
CORRELATION OF NOISY
SIGNAL
DFT VS. FFT
FILTER OF AUDIO SIGNAL

Machine Problem 1: Signal Plot


Create an M-file that allows the user to plot different types of signal as sine wave,
unit step, unit ramp and exponential functions. The limit must be a user-input.
Code:

Output:

The next output upon choosing from 1-4. Input the range and step size, then, the
graph will show.

Observation:

1. Sine Wave

2. Unit Step

3. Unit Ramp

4. Exponential

In this machine problem, the user will be the one to choose what type of signal will
be plotted. This includes its range and step size. The type of signal can be sine
wave, unit step, unit ramp or exponential function. The choices is between the
counting numbers 1 to 4. If the user chose an input beyond the range, or any
character the code will eventually go to the else part of the condition. The choices
are in if else statement functions.

Conclusion:
The different types of signal such as Sine Wave, Unit Step, Unit Ramp or an
Exponential Function is graph in this machine problem upon users choice. We can
conclude that MatLabTM is a great help in plotting a signal. This will help us, future
Engineers in dealing with signals in order for us to know what does a given signal
looks like.

Machine Problem 2: Convolution


PART 1: Create a command that computes the convolution of two signals without
using the built in command conv and the like with stem plot on its output.
Code:

Output:

Graph:

PART 2: Write an M-file script that generates and subplots the following:
a. y(n)=(n)+0.5(n-6)+0.25(n-12)+0.125(n-18).
b. Three cycles of a1-kHz sinusoid sampled at 44 KHz. Let this signal be called
x(n).
c. A damped sinusoid by multiplying x(n) by an exponentially decreasing
function. Experimentally vary the rate of decay so that towards the end of the
third sinusoidal cycle, the envelope amplitude is almost zero. What is the
value of your ?
d. Convolution of y(n) and a signal z(n)=[1,2,3,2,1]. Describe/Interpret the
resulting waveform.
Code:

Graph:

Observation:
In this machine problem, Convolution, the convolution of two signals were
computed, in the first part. this was computed by inputting the two signals and
getting its length then putting it inside a loop that correspond to the formula or
equation of convolution. Then, the convolution of the signals were graphed. In the
second part, 4 signals were graphed. The first one is the signal itself. Then, the
second one is the three cycles of a1-kHz sinusoid sampled at 44 KHz. Then, the third
one, a damped sinusoid. Then, the last one, the convolution of the first signal, y(n).

Conclusion:
In this machine problem, we can conclude that Convolution of signals can be
computed without the use of the command "conv". Using loop where the equation
of convolution is in, we can have the convolution. Using the formula's corresponding
code, we can compute its signal and graph it.

Machine Problem 3: Correlation


Write M-file functions that:
1. Calculates the end-effect corrected correlation sequence of two input
sequences from lag-0 up to lag-(N-1), where N is the length of the input
sequences.
2. (Without using xcorr,) calculates the correlation coefficient of two input
sequences from lag-0 up to lag-m, where m is also a user input.
3. (Bonus Problem:) Calculates the delay between two input sequences.

Code 1:

Output:

Code 2:

Output:

Observation:

In this machine problem, Correlation, on the first item we get the end-effect
corrected correlation sequence of two input sequences from lag-0 up to lag-(N-1),
where 'N' is the length of the input sequences. The end-effect correlation sequence
was computed by inputting the two sequences and putting it in subsequent loops
that corresponds to the equation. Then, on the command window, the end-effect
corrected correlation sequence will be shown. On the second item, the correlation
coefficient of two input sequences from lag-0 up to lag-m where computed. The 'm'
is a user input. The two sequences is also a user input and it will be computed in
two subsequent loops. Then, on the command window, the correlation coefficient
will be shown.

Conclusion:
In this machine problem, we can conclude that without using the predefined
commands like 'xcorr', we can still compute for the signals correlations such as endeffect correlation and correlation coefficient. This will be achieved with the help of
loops where the corresponding equations is in.

Machine Problem 4: Correlation of Noisy Signal


The sampled voltages from a noisy waveform are given below:
V = -7.37 -7.99 3.31 -8.59 -1.68 3.01 12.21 -2.38 7.46 -9.84 1.48 1.1 -1.8 5.48 8.93
0 -9.36 -10.11 1.61 3.36 -4.86 6.27
Using correlation, derive/estimate the periodic waveform.
Subplot v(n) and your result.

Code:

Graph:

Observation:

In this machine problem, Correlation of Noisy Signal, the periodic waveform was
estimated using correlation. The sampled voltages of the noisy waveform was
given. This was solved using loops where the corresponding equations are in. Then
the waveforms were graphed.

Conclusion:
In this machine problem, we can conclude that with the use of loops where the
corresponding equations is in, we can compute for a waveform of a noisy signal. In
this part we autocorrelate the signal to estimate the waveform using correlation.

Machine Problem 5: DFT vs FFT


1.) Using timer functions such as tic, toc and etime, measure and tabulate
the DFT computation times using your own function versus the fft function.
Repeat this procedure for different signal lengths as shown in the table below.
COMPUTE TIME (DFT Vs. FFT)

l Length (Number of Samples)


200
500

1,000

2,000

5,000

10,000

20,000

526

0.012528

0.073241

0.291599

1.167775

7.418959

30.03469

120.13876

097

0.00003

0.000048

0.000724

0.000134

0.000314

0.000677

0.001174

Plot the Compute Time versus Signal Length for the DFT and the FFT functions in
one graph/axis for comparison.
Code:

Graph:

Observation:
In this machine problem, DFT vs FFT, the computed time and the signal length was
plotted for the DFT and FFT functions in one graph. The signal lentgth or the number
of samples was given. The computed time was determined in each different signal
lengths in DFT and FFT. The DFT and FFT equations are in a corresponding code in a
loop.

Conclusion:
In this machine problem, we can conclude that using the corresponding equations
and predefined command like 'fft', we can compute for the compute time. Also, to
determine the start and end, we use 'tic' and 'toc' commands respectively.

Machine Problem 6
Part I
1. Calculate and subplot the first 30 terms of the Fourier series magnitude of each
of the following pulsed waveforms:
a. A=1; =2; T=3;
b. A=2; =2; T=3;
c. A=1; =1; T=3;
d. A=1; =4 T=6;
State your observations for each of the different results due to variation of each
parameter.
Code:

Graph:

Part II.

Let Fs=40 KHz. For each of the items below, let the magnitude of each k th harmonic
be equal to 1/k. Generate and subplot the following summations:
a.
b.
c.
d.
e.

A 200-Hz sinusoid plus its first 5 odd harmonics.


A 200-Hz sinusoid plus all of its odd harmonics.
The sum of the first 5 even harmonics of a 200-Hz sinusoid.
The sum of all even harmonics of a 200-Hz sinusoid.
A 200-Hz sinusoid plus all of its harmonics.

Code:

Graph:

Observation:
In this machine problem, On the first part, the first 30 terms of fourier series were
determined in each of the given pulsed waveforms. A corresponds to amplitudes,
tau is the pulse widths and T is the periods. These three affects the graph of the
signals or the first 30 terms of the fourier series. In the second part, the magnitude
of each harmonic is graph and the initial given is the sampling frequency equal to
40 kHz. The graphs are 200-Hz sinusoid plus its first 5 odd harmonics, 200-Hz
sinusoid plus all of its odd harmonics, sum of the first 5 even harmonics of a 200-Hz
sinusoid, sum of all even harmonics of a 200-Hz sinusoid and 200-Hz sinusoid plus
all of its harmonics.

Conclusion:
In this machine problem, we can conlude that the fourier series terms are greatly
affected by the amplitude, pulse width and the period. It is evidently shown on the
graph. Then on the second part, we can conclude that the conditions in each
harmonic, whether it is odd or even, affects the signal.

Machine Problem 7: Filtering of Audio Signal

Code:

Observation:
In this machine problem, filtering an audio signal, the a and b are the vectors
coefficients of the filter and it will filter the input data x. The 'soundsc' will play the
audio at the given fs or the sampling rate.

Conclusion:
In this machine problem, we can conclude that, MatLab TM has a capable of filtering
an audio file. It can clear out the noise and get the desired audio. The sampling rate
affects the speed and pitch of the audio.

You might also like