CS341L - Lab - 9 - Signals and System Techniques On Real-Time Data

You might also like

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

Lab-9 Signals and System Techniques on Real-Time Data

Lab-9 Signals and System Techniques on Real-Time Data


9.1 Objectives
• To familiarize with the real-time data.
• To familiarize how to read and extract real-time data in MATLAB.
• To familiarize with the techniques of signals and system on real-time data.

9.2 Software
• MATLAB2022b

9.3 Introduction
In this lab, we will implement the techniques of signals and system in MATLAB. Some of the
notable techniques are data corruption, data recovery, up and down sampling, and data fitting.
We will implement these techniques on a real-time data.

9.3.1 How to read real-time data in MATLAB

Before reading the real-time data into MATLAB, you must know the type of the data file. The file
type means that if you have the data in an Excel file, the type of that data file will be '.xlsx'.
Suppose you want to read an Excel file that contain real-time data. In MATLAB we will read this
file by following steps:
Step 1: The directory of the file you are going to read, and the directory of MATLAB should be
the same.
Step 2: If you want to read Excel file then this command is used in MATLAB
𝒅𝒂𝒕𝒂 = 𝒙𝒍𝒔𝒓𝒆𝒂𝒅(𝒇𝒊𝒍𝒆𝒏𝒂𝒎𝒆)

Figure 1: Read Excel file in MATLAB.

Step 3: If you want to read .mat file then this command is used in MATLAB
𝒍𝒐𝒂𝒅(′𝒕. 𝒎𝒂𝒕′ )
𝒍𝒐𝒂𝒅(′𝒚. 𝒎𝒂𝒕′ )

Faculty of Computer Science and Engineering CS341L: Signals and Systems Lab
Lab-9 Signals and System Techniques on Real-Time Data

Figure 2: Read .mat file in MATLAB

9.3.2 How to extract information from the real-time data file in MATLAB

In section 9.3.1, you learned how to read a file while in this section you will learn how to extract
information from a file.
Step 1: After reading the excel file in MATLAB, click on the data variable in the workspace.
Step 2: This data file has 2 columns and 629 rows. The first column contains the x-axis values
while the second column contains the y-axis value.

Figure 3: Data file in Workspace.

Step 3: Suppose I want to extract x-axis and y-axis values from this data. For this, these commands
will be used in MATLAB.
𝒙 = 𝒅𝒂𝒕𝒂(: , 𝟏);
𝒚 = 𝒅𝒂𝒕𝒂(: , 𝟐);

Faculty of Computer Science and Engineering CS341L: Signals and Systems Lab
Lab-9 Signals and System Techniques on Real-Time Data

Figure 4: MATLAB Code for Data Extraction.

Faculty of Computer Science and Engineering CS341L: Signals and Systems Lab
Lab-9 Signals and System Techniques on Real-Time Data

9.4 Lab Tasks


Task 1: Suppose sunspots data ('sunspot.mat') got point-wise multiplied by a vector 𝑽 =
[𝑽𝟏 𝑽𝟐 𝑽𝟑 … . 𝑽𝑵 ]. Plot the Original data and the Corrupted data. How are they different?
𝒂𝟏𝟏 𝒂𝟏𝟐 ⋯ 𝒂𝟏𝒏
𝒂 𝒂𝟐𝟐 ⋯ 𝒂𝟐𝒏
Task 2: Sunspot data ('sunspot.mat') got multiplied by a matrix 𝑴 = [ 𝟐𝟏 ].
⋮ ⋮ ⋯ ⋮
𝒂𝒎𝟏 𝒂𝒎𝟐 … 𝒂𝒎𝒏
Implement this operation in MATLAB and show how would you recover the original?

Task 3: Write a MATLAB code that will upsample and downsample the sunspot data (July 1985
– June 1996) ('sunspotcycle.xlsx').

1. By using MATLAB Build-in functions 'upsample' and 'downsample'.


2. By developing your own MATLAB scripts

Task 4: Write a MATLAB code that model the July 1985 – June 1996 sunspots cycle
('sunspotcycle.xlsx') as 𝑎 − 𝑏𝑐𝑜𝑠(𝑐(𝑥 − 𝑑)). Vary parameters 𝑎, 𝑏, 𝑐, 𝑑 to see which fit better.

***End Lab 9 ***

Faculty of Computer Science and Engineering CS341L: Signals and Systems Lab

You might also like