<<Importing Data>> Make sure you have downloaded all the data files off Blackboard. There should be folders...

Free

60.1K

Verified Solution

Question

Electrical Engineering

<>

Make sure you have downloaded all the data files offBlackboard. There should be folders containing images and audiofiles as well as a selection of CSV and Excelspreadsheets.

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

Task 4 – Importing ExcelSpreadsheets

Exercise:

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

Reflection:

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

- Repeat task 1 for these buildings and plot a graph showing thedifferent velocities at impact the coin would have if dropped fromthese 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 datain column 2.

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

Reflection:

- Contrast the CSV and Excel spreadsheet import processes anddescribe 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 theaudio?

- Try soundsc(x, 60000) what happens this time? Think about whythis might be happening and the importance of correctly formattingdata 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 acoloured 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.

Answer & Explanation Solved by verified expert
4.1 Ratings (544 Votes)

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)

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


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students