Lab 1 Report PDF
Lab 1 Report PDF
1
Contents
2
List of figures
Figure 1: Import audio file into MATLAB ............................................................. 5
Figure 2: Use diff() function to get a different sound from the original................ 5
Figure 3: Import and show the image into MATLAB ............................................ 6
Figure 4: The import image ................................................................................. 6
Figure 5: Import the image into MATLAB and set the conditions ......................... 7
Figure 6: For-loops and if statements .................................................................. 7
Figure 7: Comparing the 2 images after the changes in pixels (switching the blue
with the red pixel................................................................................................ 7
Figure 8: Import the image into MATLAB and set the conditions ......................... 8
Figure 9: For-loops and if statements .................................................................. 8
Figure 10: Comparing the 2 images after the changes in pixels (switching the
blue with the red pixels) ..................................................................................... 8
Figure 11: Import the Excel sheet data into MATLAB........................................... 9
Figure 12: Construct a unit step function using a user-defined function ............ 10
Figure 13: Set time array and create unit-step functions ................................... 11
Figure 14: Testing the user-defined function ..................................................... 11
Figure 15: Graph for the three function............................................................. 12
Figure 16: Create and plots the sinusoids .......................................................... 12
Figure 17: Plot the three sinusoids in subplots .................................................. 13
Figure 18: Graph of the 3 sinusoids function ..................................................... 13
Figure 19: Setting the parameters ..................................................................... 14
Figure 20: Plot the real and imaginary part ....................................................... 15
Figure 21: The real and imaginary part of the complex exponential .................. 15
Figure 22: Graph of complex number ................................................................ 16
3
Introduction
In this lab, we will be revising some of the essential function of
MATLAB.
4
Part 1: Revision from first year
Task 1: Reviewing of importing and manipulating audio in MATLAB
Exercise:
- Using the diff() function to find the derivative of the audio, and we get a higher sound
than the original audio:
Figure 2: Use diff() function to get a different sound from the original
Reflection:
1. How did the sound of the audio differ between the original and differenced version?
- At first we have the original sound of the audio (string.wav) imported into MATLAB and
played using the function soundsc(), then we apply a filter using the function diff(). By
using the diff() function to the audio file (string.wav), we are basically finding the
derivative of the signal which we imported in. And this would result in a distinct audio
which is different from the original.
- The filter which was used to process the sound file was a high-pass filter which amplified
the sound and gives it’s a higher frequency than the original.
2. Describe what is a filter is in the context of electrical and electronic engineering.
- In signal processing, a filter in the context of electrical and electronic engineering is a
device or a process that removes unwanted elements form the signal. [2]
- Different types of filters: FIR Filters, IIR Filters, High-pass and Low-pass, Band-pass, etc.
[2]
5
Task 2: Reviewing of importing & manipulating images in MATLAB
Exercise:
- Use imread() and imshow(x) to import and display the image “lygon.jpg”:
- Imread() is to read the jpg image file, imshow() is to show the image.
6
Create a MATLAB script (with if-statements and for-loops) that finds every pixel:
Figure 5: Import the image into MATLAB and set the conditions
Figure 7: Comparing the 2 images after the changes in pixels (switching the blue with the red pixel
7
Reflection:
- Replace the blue colored pixels with the corresponding pixel in the image ‘tartan.jpg’.
- Just similar to the pervious exercise we import the image to MATLAB and set the
condition:
Figure 8: Import the image into MATLAB and set the conditions
Figure 10: Comparing the 2 images after the changes in pixels (switching the blue with the red pixels)
8
Explain chroma-keying and give examples from references of when this is used in the
entertainment industry.
- Chroma key composting or chroma keying, is a visual effects/post production technique
for composting (layering) two images or video streams together based on color hues
(chroma range). This technique has been used heavily in many fields to remove
background objects or colors of a video or images. [3]
- Some example of the chroma-keying (green-screen effect):
+ Weather forecast broadcasts, where the news presenter is always seen to be standing
in front of a huge CGI map, but actually is a large green screen background.
+ The chroma-keying is also commonly used in the visual effects in the entertainment
industry in movies and video games. For examples the movie Star War is a big user of
the green screen effect for those epic battles in space. In video game, the developers
use the chroma-keying to create a scenario in the game by combining 2 different images
and changing the colors to fit into the theme of the game.
- Import the Excel sheet ‘JBHiFi.xlsx’ which contains the stock prices for JB HiFi over one
financial year.
Think about some of the other statistical tools MATLAB has and how they could be
applied to this data to extract different information or to visualize this data in
different ways
- Other method that could be used to analyze the data to extract and visualize data:
+ Probability Distribution Objects: Allow you to fit a probability distribution to sample
data, or define a distribution by specifying parameters values.
+ Hypothesis Testing: Test a statistical sample, with the goal of accepting or rejecting
a null hypothesis. The test tells the analyst whether or not his primary hypothesis is
true.
+ ANOVA (Analysis of variance and covariance): a procedure for determining whether
variation in the response variable arises within or among different population groups.
+ Classification: classify new observations from examples of labeled data. To explore
classification models interactively.
+ Statistical Visualization: Show the relationships between variables using bivariate
plots such as grouped scatterplots and bivariate histograms.
+Descriptive Statistics: Compute descriptive statistics from sample data, including
measures of central tendency, dispersion, shape, correlation, and covariance. Tabulate
and cross tabulate data, and compute summary statistics for grouped data.
10
Reflection:
11
Figure 15: Graph for the three function
- Create and plots 3 sinusoids and plot them on three subplots in MATLAB:
+ Create a time array of length 1 second with a step-sized of 1/44100 Hz and create
three of the following sinusoids.
12
+ Plot the three sinusoids in three subplots in MATLAB.
13
Reflection:
- Using the same time array from the previous task, create a complex exponential with a
frequency𝑓 = 50 𝐻𝑧.
- Setting the parameters.
14
- Plot the real and imaginary part.
Figure 21: The real and imaginary part of the complex exponential
15
Reflection:
Conclusion
To sum up, in this lab report, for the part 1, we are using the MATLAB for
importing and manipulating audio, images and Excel data. For example, in
task 1, we use the function to generating the sound which is higher frequency
than the original. In task 2, we can change the blue colored pixels with the
corresponding pixel in the image ‘tartan.jpg’. For the part 2, we continue to
use MATLAB for generation the unit-step function, a sinusoidal waveforms
and complex exponentials. For instant, in task 5, to create and plots 3
sinusoids, we have to create a time array of length 1 second with a step sized
is 1/44100 Hz and create three of the following sinusoids. In the task 6, as
same as task 5 we use the time array to create the complex exponential with
𝑓 = 50 𝐻𝑧, after that we plot the real and imaginary part.
Peer assessment
Work assessment Contribution
Writing the report, writing and
Pham Ba Dat – s3687451 fixing the code format. (task 1,2) 33%
Writing, checking the code and
Tran Trong Tin – s3694839 fixing the code format.( Task 33%
4,5,6)
Writing the report, writing and
Tran Do Chi Hai – s3653997 fixing the code format. (task 3, 4) 33%
17
Reference
[1] https://en.wikipedia.org/wiki/MATLAB
[2] https://en.wikipedia.org/wiki/Electronic_filter
[3] https://nevadafilm.com/production-notes-chroma-keying-and-green-screens/
[4] http://mathworld.wolfram.com/EulerFormula.html
18