Week 3 – Data Input/Output & Plotting

Learning Outcomes By the end of this week, students will be able to:

  1. Understand and use different data types in MATLAB.
  2. Import and export data between MATLAB and common formats (CSV, Excel, MAT).
  3. Organize data using arrays, tables, and timetables.
  4. Perform simple data cleaning and transformations.
  5. Produce basic 2D plots and customise them.
  6. Save figures and outputs for reports.

Suggested Readings

In-Class Activities

  • Import data using
  • online sources: API vs direct URL.
  • CSV/Excel files.
  • Convert imported data into MATLAB tables and timetables.
  • Diagnose missing values and handle them (rmmissing, fillmissing).
  • Compute year-on-year GDP growth from quarterly data.
  • Plot GDP levels and YoY growth with:
  • Titles, axis labels, and legends.
  • Automatic colour + varying line styles for multiple series.
  • Save outputs:
  • Cleaned dataset to .mat and .csv.
  • Plots as .png and .fig.

Homework / Practice

  • Download real GDP (constant prices, 2015=100) for all available countries from the World Bank (via API or direct CSV).
  • Build a panel dataset in MATLAB and convert to a table.
  • Compute for each country:
    • Log of GDP
    • YoY growth rates
  • Select some countries of your choice
  • Produce and save plots:
    • Real GDP levels on the same plot with different colours/styles +legend.
    • Each country YoY growth rate on a different subplot plus a line showing the average growth rate over the sample.
    • Export the cleaned panel dataset and figures.

Files

Homework submission

  • Submit your homework here
  • Please upload your homework as a single zip file. Access it’s now open with any email address! But remember to name your file with your full name and or student ID.
  • The submission should include the .m file used to produce the results.
  • You can modify you submission until the beginning of week 4.