Importing Data Exercise

This section involves an exercise that gets you to practice importing data. If you get stuck, there are sample codes at the end of the exercise that you can use as a guidance. Don’t open the sample codes unless you have attempted the steps below to the best of your ability.

 

Exercise 2.1

Download the files below and save them into a folder called ‘Reading Data and Graph Plotting’, without the quotation marks. Then follow the instructions below.

Download:

  1. Set your working directory (current folder) to the path of the folder that you have just created.
  2. Write MATLAB commands to read in the data from each of the four files (Hint: the data needs to be adjusted so that MATLAB can read it in). This can be achieved by creating an edited M-file for each of the text files provided. You should think of suitable variable names for each file.
  3. Create a “controlling” M-file that calls the others that you have created for point 2. This will be used to introduce the variables into MATLAB without the user having to import each set of data one by one every time. Entering the name of this M-file into the Command Window should do everything for you.
  4. Check your code with the sample code attached below. There is no right answer for this assignment; so long as your code works and performs what it meant to do, then you’re right! However, your code should be similar to the sample code below due to the nature of the instructions.

Download: