Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<<Importing Data>> Make sure you have downloaded all the data files off Blackboa

ID: 3349620 • Letter: #

Question

<<Importing Data>>

Make sure you have downloaded all the data files off Blackboard. There should be folders containing images and audio files as well as a selection of CSV and Excel spreadsheets.

The following exercises will allow you to practice using MATLAB’s import/export functions.

Task 4 – Importing Excel Spreadsheets

Exercise:

Import the spreadsheet ‘buildings.xls’ which contains all the buildings in the world over 300 metres tall. Plot the number of floors vs. building height using a scatter plot.

Reflection:

- Look at how Excel data is imported into MATLAB. How is the text stored? How are the numbers stored?

- Repeat task 1 for these buildings and plot a graph showing the different velocities at impact the coin would have if dropped from these buildings instead.

Task 5 – Importing Comma Separated Values (CSV) files

Exercise:

In your MATLAB script file import the comma separated values in ‘scope1.csv’. This data has time data in column 1 and voltage data in column 2.

- Split the data into separate time and voltage arrays and plot voltage with respect to time.

Reflection:

- Contrast the CSV and Excel spreadsheet import processes and describe how the two differ.

Task 6 – Importing Audio files

Exercise:

In your script file, import the .wav file called ‘gameover.wav’: - Use the soundsc() function to listen to this audio.

Reflection:

- Try soundsc(x,30000) what happens to the playback of the audio?

- Try soundsc(x, 60000) what happens this time? Think about why this might be happening and the importance of correctly formatting data you are exporting from MATLAB.

- Try some of the other sound files in the audio folder.

- Refer to your tutorial notes from week 3 for more details.

Task 7 – Importing Images

Exercise:

Use the MATLAB script file to import the image ‘barbara.png’:

- Display this greyscale image using imshow().

- Now import and display the image ‘lena.tiff’, this image is a coloured image.

Reflection:

- Contrast the black-and-white image to the coloured image. Compare how they are stored as MATLAB matrices.

- Refer to your tutorial notes from week 3 for more details.

Explanation / Answer

Image Read and Display:

-------------------------------

I = imread('barbara.png'); % reading image
imshow(I) % dislpay image
I_1 = imread('lena.tiff');
imshow(I_1)

--------------------------------------------------------

The black and white images are saved as binary(0,1) matrix while the coloured image are stored with some distinct values defining the colour of that pixel.

----------------------------------------------------------------------

Importing Audio file in matlab

---------------------------------

[x,Fs] = audioread('gameover.wav'); % reading file from current directory
soundsc(x,30000); %listening at 30Khz
pause;
soundsc(x,60000); %listening at 60Khz

-------------------------------------------------------------

Reading .csv file

=---------------------------------------------------------------

M = csvread('scope1.csv');
voltage = M(:,1);
time = M(:,2);
plot(time,voltage)

-----------------------------------------------------------

Importing excel file in matlab

---------------------------------------

num = xlsread('building.xls');
floors = num(:,1);
building_heights = num(:,2);
scatterplot(floors,building_heights)

=======================================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote