Project 1 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

TE2035 Signals and Systems Analysis

Project 1: Introduction to the Use of MATLAB

Members:

Jennifer Daniela Nolasco Juárez A00820852

Luis Enrique Zapata Arellano A00823336

Miguel Angel Mas Cano A01039861

Paola Villarreal Prieto

1
Table of Contents

Introduction Page 3

Background Page 4

Problems Pages 5-17

Exercise 1 Pages 5-6

Exercise 2 Page 6

Exercise 3 Page 7

Exercise 4 Page 8

Exercise 5 Pages 8-9

Exercise 6 Pages 10-11

Exercise 7 Pages 11-13

Exercise 8 Pages 14-15

Exercise 9 Pages 15-16

Exercise 10 Pages 16-17

Result and discussion Page 18

Conclusion Page 18

References Page 19

Annex 1 Page 19

2
Introduction

MATLAB is a powerful programming tool used in a variety of settings such as data


analysis, however this complex program requires dexterity from the user to be fully
taken advantage of.

This project aims at signal processing with the help of technology, focusing on the
creation and visualization of vectors, which are the basic tool for graphing the
signals.

The focus of this activity is to start using Matlab and its basic commands about
signals, which serve as the basis for any subsequent project. Thus the present work
will allow us to show different examples applying the basic commands and tools.

This document consists of ten problems in which some of the basic functions of
Matlab are applied, accompanied by their respective graph, in which you can
observe the behavior of each function.

3
Background

MATLAB is a programming platform designed specifically for engineers and


scientists.

MATLAB is characterized for using its own language, which is a matrix-based


language allowing the most natural expression of computational mathematics.

Using MATLAB you can:


● Analyze data
● Develop algorithms
● create models and applications

MATLAB is also widely used by undergraduates for educational and academic


purposes

So far during the Signals and Systems Analysis course, we have learned about the
characteristics and classification of different signals.

All of the different signals we have seen so far can be expressed and visualized
through MATLAB and its variety of functions.

4
Problems

Exercise 1.​ For the the vector x = rand(1,100), graph plot(x) y stem(x).

Figure 1. Graph of the plot function

Figure 2. Graph of the stem function

5
Two different types of signals (continuous and discrete) were obtained due to the
functions used plot and stem, but each one reflected the same data sequences.

The graph shows the reference values of the antimullerian hormone, which is a
marker used to assess the fertility status of women, see [1]. In this case, one
hundred samples were taken from different women to assess the value of the
hormone according to the reference value (See Table 1.).

Hormone AMH Value

High 1 - 2.9 ng/ml

Normal low 0.7 - 0.9 ng/ml

Low 0.3 - 0.6 ng/ml

Very low < 0.3 ng/ml


Table 1. Reference values of the hormone AMH

6
Exercise 2.​ Read the ecg.txt file that you can find in Blackboard, which contains the
values of an ECG signal captured every X ms.

Because we are the team number 10, the value that took the variable X was 22 ms.
X = 2 + 2 * group nº

Figure 3. Graph of the ECG

What can you say about the signal obtained?

The signal obtained is an electrocardiogram, which is read from the text document
previously given with the help of the textread function.

7
Exercise 3.​ Load the ecg.txt file and zero the vector values below 0.5. Values
greater than or equal to 0.5 multiply them by 2.

Figure 4. Graph of the altered ECG

The generated signal comes from an electrocardiogram, only that in this exercise
according to the database, the values below 0.5 became zero and above and equal
to 0.5, the value was multiplied by two, resulting in a signal without negative values,
deforming the original signal.

Exercise 4.​ Create and visualize a causal sinusoidal signal of length 100, period X
and amplitude Y.

Since we are team number 10, the value taken by the period X variable was 28 and
the value taken by the variable amplitude Y was 23.
X = 8 + 2 * g roup noº Y = 3 + 2 * g roup noº

8
Figure 5. Graph of the sinusoidal signal

The generated sinusoidal signal was 100 data long, said signal was based on the
general sinusoidal formula A * sin (wt + phi). The x-axis is the time, which has as a
unit milliseconds and the y-axis is the voltage, which has as a unit volts. The signal
obtained does not have any complexity, since it does not have any lag, in addition
the formula is very easy to use and apply.

Exercise 5. ​Create 3 sinusoidal signals with length 100 and periods (1 + group
number), (2 + group number) and (4 + group number), respectively. Visualize the
signal generated by the sum of the 3 sinusoidal signals.

Because we are team number 10 and we need three period values, the values were
as follows:
a. P eriod 1 = (1 + group noº) = 11
b. P eriod 2 = (2 + group noº) = 12
c. P eriod 3 = (4 + group noº) = 14

9
Figure 6. Graph of the sinusoidal signals

The generated signal is a sum of three sinusoidal signals, each one was based on
the general sinusoidal formula A * sin (wt + phi), on the other hand the difference
between each one was the value of the period.
In general, the generated signal has a certain complexity value, since in this case
there are three signals in one.

Exercise 6​. ​Create and display a triangular signal with support in [(-50+group
number), (50+ group number)] ms. The support of a function is defined as the
domain subset within which the function takes non-zero values. Assign values to the
axis command so that the graph can be seen in the intervals [(-60+group number),
(60+group number)] in "t" in ms, and [-0.5, 6] in the y-axis. Consider an amplitude of
5 Volts.

Lower bound would be ‘-50+g’, and the upper ‘50+g’, being ‘g’ the team number. The
period if we want the base of the function in the lower bounds, the period would be
‘upper - lower = 100’. We then use:

x=A.*tripuls((n-g)/T);
I=x>0;
y=x.*I;

10
to set the pulse and leave out any value lower than 0. ‘A’ of the pulse is set to be 5
from base to highest value.
The functions ‘xlim([(-60+g) (60+g)])’ and ‘ylim([-0.5 6])’ help us set the right scale for
the plot. For the shift we use ‘n-g’ instead of n.

Figure 7. Graph of the triangular pulse

The obtained signal is as expected. Consulting in Matlab’s help section, the tripuls
function is used to get a pulse aperiodic signal. For a periodic one there’s a function
of sawtooth plots.

Exercise 7.​ ​Create and visualize a pulse signal in the interval [(-40+group number),
(40+group number)] in "t" in ms and [-0.5, 6] in the y-axis, with support in [(-20+group
number),(20+group number)] and length 121. Use the command “stem” to plot your
graph. Consider an amplitude of 5 Volts.

We just modify the last program done to include steps different than 1 and have a
vector of ‘L = 121’ values:

n=lower:((upper-lower)/(L-1)):upper;

We also change the period, ‘T’, the limits, and the type of function.

11
Figure 8. Graph of the square pulse

Now, create two copies of the previous pulse signal, the first one delayed 10 ms and
the second one delayed 20 ms and a quarter wide.

To keep the program modular we just introduce the variant ‘offset’, which allows us
to make the changes in many parts at the same time. There are only two changes;
the inclusion of ‘offset =’ with a 10 or 20 and the ‘g=10+offset’.

12
Figure 9. Graph of the square pulse delayed by 10 ms

Figure 10. Graph of the square pulse delayed by 20 ms

They look almost exactly like the original. Adding a delay didn’t change anything
except for the time at which the pulse occurred, so we can say that the pulse
function is time invariant.

13
Exercise 8. ​Create and visualize a causal complex exponential signal of length 200,
period 20 ms and amplitude (1 + group no.), (2 + group no.) and (4 + group no.)
Watts.

We only use the suggested formulas to find the amplitude based on the group
number, which in this case is number ten and we use tools to combine the graphs
and to compare them in the same 3D plot

Figure 11. Graph of the complex signals in time, with their respective amplitudes. Side to
side and compared in the same graph

To generate the graph that will be the sum of the three exponentials we use the next
lines of Matlab code:

A1=1+g;
A2=2+g;
A3=4+g;
x1=A1*exp(1j*(2*pi/T)*n);
x2=A2*exp(1j*(2*pi/T)*n);
x3=A3*exp(1j*(2*pi/T)*n);
x=x1+x2+x3;

14
Figure 12. Graph of the sum of the complex signals

The signal came out as expected, since it’s just the sum of the others. The only thing
that changed is the amplitude.

Exercise 9.​ In a couple of graphs, visualize the magnitude and phase of the complex
exponential from the previous exercise. Title the graphics and label the axes.

Figure 13. Graphs of the magnitudes of the complex signals

15
Figure 14. Graphs of the phases of the complex signals

The first graph shows that, in a complex “spiral” generated by complex rotation, the
magnitude remains constant throughout. The magnitude of the sum of the other
complex signals has a higher magnitude.

For the second graph the samples had to be increased to get more resolution. The
graph looks like a screw. All of the graphs generated give us the same information.

Exercise 10. A ​ square signal can be generated in MATLAB with the "square"
function and a sawtooth signal is generated with the "sawtooth" function. Check the
MATLAB help to understand how these functions are used and generate a figure for
each function in the time interval [0, 4 * pi * group number] with increment of 0.01.
The amplitude of each signal will be [-2 , 2] Volts. Each figure must be gridded (with
grid). Assign values to the axis command so that the graph can be seen in the
intervals [-1, (4 * pi * group number) + 1] in "t" in ms.

Here different types of periods were used to get to a higher resolution. The details
were almost the same as in the previous exercises and there’s the reuse of the
bound lines.

16
Figure 15. Graphs of the square and sawtooth signals

The sawtooth signal is a bit too specific, but it can be reversed. As an electric signal
it would be intuitive if that would cause less energy costs.

17
Result and discussion

Throughout the ten problems, different functions of Matlab were analyzed. It began
using two ways of displaying signals, with the help of the functions: plot and stem,
which generated the previously established vector.
Also, in order to work with a .txt text document, the file had to be read and stored in a
variable, so that it could be maneuvered as we wanted. On the other hand, pulse
signals, sinusoidal, triangular and exponential were created, which are of essential
use to demonstrate the behavior of many systems.

Conclusions

MATLAB and its many functions proved sufficient and easy-enough to use for
implementing the answers for all problems.

We were able to plot graphs of vectors for both discrete and continuous values,
extract data from external files, and use different kinds of signals such as sinusoidal,
exponential, squared and triangular and rectangular pulses.

It is also possible to plot complex functions using a tri-dimensional plane and


represent real and imaginary values of such functions in a bi-dimensional plane.

MATLAB is excellent for applying basic operations with signals in almost the same
way as seen in class and observing the graphical results; it can be done by using
pure numeric values, and also with a more code-like approach.

Now, with the knowledge of these basic MATLAB functions, we will be able to
execute further projects for the course adequately.

18
References

[1] MathWorks. ​What is MATLAB?​ mathworks.com. Accessed 03, 2020, from


https://www.mathworks.com/discovery/what-is-matlab.html

[2] Romero, D. and Salvador, Z. (2018). ​La hormona antimülleriana: utilidad para
estudiar la fertilidad.​ [online] Reproducción Asistida ORG. Available at:
https://www.reproduccionasistida.org/la-hormona-antimulleriana-amh/ [Accessed 23
Feb. 2020].

Annex 1

Distribution of the work:

Luis Zapata: Exercises from 6 to 10.

Jennifer Nolasco : Introduction and exercises from 1 to 5.

Miguel Mas: Format check for all the document, table of contents, background and
conclusion.
 

19

You might also like