Types of Signals with plotting in MATLAB

Hello! Welcome to the engineering projects. This is the second part of the signal and system series in which we will discuss some essential classifications of simple signals. In the previous session, we discussed the introduction of signals and systems and also ran some simple codes on MATLAB for the implementation of some simple codes.

In this session, we are discussing some essential types of signals, and the best part is that we will implement all the signals in MATLAB for the best understanding. Here is a quick glance at all the topics that we will discuss today:

  • Continuous-Time Signals

  • Discrete-Time Signals

  • Periodic Signals

  • Aperiodic Signals

  • Even Signals

  • Odd Signals

  • Deterministic Signals

  • Non-Deterministic Signals

  • Energy Signals

  • Power Signals

  • What are functions? 

  • Some examples of signals

  • Difference between some signals

Continuous-Time Signals

It is a signal that does not contain any breaks and is referred to as a continuous-time signal.

Differential equations are used to describe this. This signal is represented by the letter x(t). Because of their historical significance, CT signals are frequently referred to as analog signals.

Example

Controlling the speed of a DC motor by the use of a tacho generator's feedback, sine waveforms, or exponential waveforms. The well-known mathematical concepts of differential equations, continuous convolution operators, Laplace transforms, and Fourier transforms are what differentiate linear CT systems from other types.


Discrete-Time Signals

A signal is said to have a discrete-time signal if its value can be measured at discrete intervals. There will be time intervals of n during which you do not have a value when you are working with a discrete-time signal. The form x[n] is utilized in the representation of DT signals. Continuous-time (CT) signals are approximated by discrete signals.

Example

Difference equations, discrete convolution operators, Z-transforms, and discrete Fourier transforms are some of the mathematical tools that can be used to represent linear DT systems.

Once you have understood these concepts, you must know there are further types of these signals as well. Keep in mind that every signal is continuous or discrete, and these are further divided into sub-types. These sub-types are given next:

Periodic Signal

A signal is said to be periodic if it satisfies the following equation:

π‘₯(𝑛) = π‘₯(𝑛 + 𝑁);   

where n is a positive number. In other words, a signal is said to be periodic if it repeats the same sequence of values exactly after a predetermined amount of time, which is referred to as the period.

Example:

Sine Wave 

MATLAB Code for Periodic Signals

Here, we are going to present some lines of code that when entered into the MATLAB window, you will observe a sinusoidal wave. 


Code


A=7;

f=10000;

T=1/f;

t=0:T/10:5*T;

y1=sin(pi*f*t);

plot(t,y1)

xlabel('Time')

ylabel('Amplitude')

title('Periodic Signal')

grid on



Explanation

As we know, all waves have an amplitude, frequency, and time period. Simple code is explained in our previous lecture, but in this code, you must notice that the amplitude and the whole wave repeat their pattern after a particular time period that is exactly the same as in the previous section. 

Aperiodic Signals

As you can guess from the name, an aperiodic signal is one that can be represented as

π‘₯(𝑛) β‰  π‘₯(𝑛 + 𝑁); 

Here, n is a positive number.


The signal does not repeat itself after a particular time interval; instead, it has a different pattern at every point. 

MATLAB code for an Aperiodic Signal


Code

Output

fs = 15000; 

ts = 1/fs;

tpuls = 10e-3;

f1 = 94;

f2 = 9000;

N= 20;

t=0:ts:tpuls;

null/t=0:ts:tpuls;

y = chirp(t, f1, t(end), f2);

plot(t, y, 'b*-');

title('Non-Periodic Wave')

xlabel('Time/ The Engineering Projects')

ylabel('Amplitude')

grid on;


Explanation 

As you can see in the output, the wave’s pattern is not predictable. You can do the same thing by using a β€œRandom” function that you will see in this same article in just a bit. For now, there is no need to understand all this code, you just have to observe the pattern in the output.


Even Signal

The term "even signal" or "even function" refers to a signal that is symmetrical at the time origin or the vertical axis, respectively. The even signals are also referred to as symmetrical signals for this reason.

Mathematically, 

x(-n)=x(n)


In other words, the values on the right-hand side are exactly symmetric to the left-hand side of the axis.

Example 

Cosine Wave

Odd Signal

A signal is referred to as "odd" if it is anti-symmetrical on the vertical axis. An odd function is another name for an unusual signal. As a result, the signals that are odd are sometimes referred to as antisymmetric signals.

Example

Sine Wave

MATLAB Code for Odd Signals


Code

Output

n=-2:12

x=sin(4*pi*n/5)

subplot(2,2,1)

plot(n,x)

title('Odd Signal')

xlabel('Time/ The Engineering Projects')

ylabel('Amplitude')

grid on;

xo=-sin(4*pi*n/5)

subplot(2,2,2)

plot(n,xo)

title('Odd Signal')

xlabel('Time/ The Engineering Projects')

ylabel('Amplitude')

grid on;



Explanation

Here, in the output, you can see two signals. When we replace the equation with the negative sign, we find that it is flipped and is non-identicle to the first picture. Hence, it is an odd signal. 


Deterministric signals

When there is no room for interpretation regarding a signal's value at any given moment in time, we say that the signal is deterministic. Or, signals are referred to as deterministic when they are capable of being characterized in an accurate manner by a mathematical formula.

Let’s say we have a formula that shows an equation or a signal, then we can predict the result or the graphical representation with the help of that formula, and such signals are referred to as deterministic signals. 

Example

sine wave, square wave.

MATLAB Code for Deterministic Signals


Code

Output

n=-2:10

x=sin(4*n/5)

subplot(2,2,1)

plot(n,x)

title('Deterministric Signal')

xlabel('Time/ The Engineering Projects')

ylabel('Amplitude')

grid on;



Non-deterministic signals

These are contrary to the one that was discussed before. The result of such signals is not predictable, and therefore, a formula can not be set to represent non-deterministic signals. In one case, they are shown with a certain value, and in the next case, the values change abruptly.  Because of the nature of providing random values with these signals, they are also called random signals. 

Example

Noise in communication is an example of random signals because no one can exactly predict the noise value during communication.

MATLAB Code for Non-Determinsitric Signals


Code

Output

x=rand(1,100);

plot(x)

title('Random Signal')

xlabel('Time/ The Engineering Projects')

ylabel('Amplitude')

grid on;



Explanation

Here is an interesting example for beginners. Basically, this code comprises two steps that are used in the functionality of the signal. We have used a function called β€œRandom” and represented as rand(a,b) where a and b are the peak values in between which, this function displays any number randomly without any pattern. In the next step, we will just plot the signal and got the perfect example for the random function. 



Energy Signals

Energy signals are the ones that contain a finite amount of energy in them. The energy of such signals can be calculated using different techniques, but the power of such signals is infinite. Mathematically, 

0 < 𝐸 < ∞

Example

Aperiodic signals


Power signal

In contrast to energy signals, power signals have a finite power that can be observed and measured, and the energy of these signals is infinite. By using mathematical representation, we can say, 

0 < 𝑃 < ∞


Example

Periodic signals

Functions in MATLAB

Just like any other programming language, MATLAB also has some pre-defined functions and in this course, we will use some of these according to the need of time. You have observed that some functions are also present in the codes that we have discussed today and now, we are going to discuss some explanations about these functions so that you may have an idea about the working and needs of these functions. 

We can write a function independently from the main program, without having to consider how it will interact with the rest of the program as we do so. A function can be thought of as a miniature version of the main program. Because of this, we are able to break down a large program into smaller, more manageable portions, which ultimately results in a reduction in the total complexity of our program.


Flipped Function

Flip is an interesting function in MATLAB that can be used to flip the whole signal in just one step. There is no need to write the code with different signs and information. Mathematically, the flip function is given as

B = flip( A, dim )

Where

B= Any variable that is used to store the result of the flip function so that you can take further steps. 

A= The signal that is to be flipped. You can also give the signal to any name.

Dim= dimensions at which you want to flip your signal. 

Usage

We have used this function in our code where we had to find that is our signal even or odd. It is just an example. This function is also used in other codes according to the needs of the programmer. 

Random Function

Random Function is used to have a uniformly distributed random number that is set by the programmer according to need. There are different forms of random functions that are used in random functions and some of them are:

Y = rand(n)

Y = rand(m,n)

Y = rand([m n])

Y = rand(m,n,p,...)

Y = rand([m n p...])

Y = rand(size(A))


Out of which we have used the second one, where we have given the two dimensions to the random function. This returned us an m-by-n matrix of random entries, and we used it for our aperiodic signals.

In the case given above, the result of this random function is stored in the Y variable so that it can be used again for more actions.


Difference Between Some Signals

While using these signals in our codes, one must be clear about the difference between some same kinds of signals and it is a good practice to have to keep them in mind in the form of points so that you may have the idea about the best use of these signals. Here are some important points to keep in mind. 

Continuous-Time Signals

Discrete-Time Signals

  • This signal can be defined at any time instance, and its values can take any of the ones found in the continuous interval (a, b), where a can be negative and b can be positive. This signal can also be defined at any time.



  • Discrete-time signals can be measured at regular intervals. In a discrete-time signal, there are n-second gaps with no data. DT signals are x[n]. Discrete signals replace CT signals.

  • Have more Information

  • Have less information

  • Need More Memory

  • Need Less Memory

Periodic Signal

Aperiodic Signal

  • Repeat the sequence 

  • Does not repeat the sequence

  • Future value can be predicted

  • Future value can not be predicted

Even Signal

Odd Signal

  • Remain same at both sides of axis

  • Does not remain same at both side of axis

  • Easy to handle

  • Slightly difficult to handle

Deterministitric Signals

Non-Deterministitric Signals

  • Can be represented as a formula

  • Can not be represented as a formula

  • Easy to use

  • Difficult to use

Energy Signal

Power Signal

  • Energy of the signal is finite

  • Power of signal is finite



Conclusion

Signals have a different type but all of these can be represented as discrete or continuous. We use these types many times while we are dealing with the signal and system and it is important to have the idea of pre-defined functions so that we may minimize the code size with fewer errors. 

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir