Introduction to MATLAB for Oceanographic Data

Anna Pfeiffer-Herbert, Stockton University, Marine Science
Author Profile

Summary

This activity introduces students to loading and plotting data in MATLAB. Students explore scalar and vector time series and profile data commonly used in the field of Oceanography using data sets from publicly available sources or that they collected in local waters.


Learning Goals

The primary objective of this activity is to have students become comfortable with using MATLAB as a tool for working with time series and profile data. At the end of this lesson, students will be able to:

  1. Load data obtained from other sources in Excel format into the MATLAB workspace
  2. Use built-in functions to calculate descriptive statistics (mean, standard deviation) of the data set
  3. Run a MATLAB script to produce the following graph types: line graph, scatterplot, vector timeseries, polar histogram, line graph with inverted axes
  4. Interpret graphs using scientific content knowledge
  5. Modify a MATLAB script to create new graphical output of a novel data set

Context for Use

This activity was designed for an introductory-level undergraduate laboratory accompanying an Introduction to Oceanography course for students (first year majors) with no prior experience in MATLAB. Students completed the activity in 2.5 hours, with some additional time outside of class to write a report. The activity could be adapted as a homework assignment with a shorter amount of class time spent on introducing basics of MATLAB. Students should be familiar with basic Oceanographic concepts such as salinity, density, tides, and velocity vectors. Students should also have a basic working knowledge of Excel or similar spreadsheet software.

Description and Teaching Materials

Students receive the attached handout and are directed to download a zipped folder of MATLAB scripts and Excel spreadsheets from the course management system.

I begin class with a brief lecture on the types of data we will work with (Introduction to Ocean Data Powerpoint). An example of elevated water levels during Hurricane Sandy is used as a hook, which many of the students relate to as an impactful event to the Mid-Atlantic region of the U.S.

To provide an overview of MATLAB software, I walk through Matlab_example1.m section by section and circulate to make sure every student has a working copy of MATLAB running.

Students then work in pairs through the rest of the activity handout exercises in order:

1. Tide data (plot_tides.m): This part of the activity begins with time series graphs and use of functions in the Command Window. The students import Excel data from two tide gauges (Learning Goal #1), find the center and spread of the data with basic statistical functions (Learning Goal #2), and create a new variable.

2. Wind data (plot_wind.m): This script introduces new graph functions (quiver and compass) for use with vector data (Learning Goal #3). Students are asked to describe changes in the data over time and compare multiple time series (Learning Goal #4).

3. CTD data (plot_ctd.m): This script demonstrates how to invert axes for vertical profile graphs commonly used in Oceanography (Learning Goal #3). It also requires modification of the script to convert units.

After completion of the in-class activity, students apply these techniques to a new time series data set (Learning Goal #5) and prepare a written report that collects figures, figure captions and a written interpretation of the data (Learning Goal #4).

The activity focuses on physical oceanographic data sets from sources near our institution because it is used in a methods course for Oceanography majors. It can easily be modified to use oceanographic data from other locations (or data from different disciplines altogether). MATLAB was selected as the primary software to prepare students in the course for an upper level MATLAB-based programming course and/or for working on independent research with faculty. Equivalent software (e.g., Python) could be substituted to achieve the same objectives, especially at institutions without a MATLAB license.

Student handout (Microsoft Word 2007 (.docx) 24kB Nov8 19)

Matlab_example1.m (Matlab File 1kB Nov8 19)

Tide and Wind Data (Excel 2007 (.xlsx) 69kB Nov8 19)

CTD Data (Excel 2007 (.xlsx) 15kB Aug19 19)

Matlab script for tide data (Matlab File 1006bytes Nov8 19)

Matlab script for wind data (Matlab File 2kB Nov8 19)

Matlab script for CTD data (Matlab File 1kB Nov8 19)

Introduction to Ocean Data (PowerPoint 2007 (.pptx) 6.3MB Nov8 19)

Teaching Notes and Tips

Students with no prior coding experience often feel overwhelmed at the start of the activity. I spend a good deal of time walking through the various MATLAB windows and the example script with the whole class. If the class has mixed experience, pairing novice and experienced students together works well (have the novice student type and experienced student coach).

The sample scripts are scaffolded to build confidence from running a pre-made script to small modifications to starting a new script from scratch. I encourage students to copy snippets from the sample scripts and edit them to work for a new context. The students are also asked to thoroughly annotate their work to demonstrate that they understand each portion of the code.

Data are supplied in Excel format intentionally because students complete this activity after a few weeks of working with data in Excel and because the data sources that we use were obtained in Excel or CSV format. To skip the step of importing data with the Import Data wizard, the scripts could be modified to load the data programmatically (i.e., with xlsread). These data could also be supplied to the students in .mat format.

Assessment

Students submit a written lab report with tables and figures produced by their MATLAB scripts and copies of their edited and annotated scripts. The reports and scripts are evaluated for completeness of the MATLAB scripts, correct production of scientific graphs, captions that demonstrate understanding of the content of each graph, and evidence of application of oceanography content knowledge in the written interpretation of the graphs. A sample rubric is attached.

Rubric for Intro to Ocean Data reports (Microsoft Word 2007 (.docx) 20kB Nov8 19)

References and Resources

Water level and meteorological data obtained from NOAA Tides and Currents

Stations used in this activity:
Atlantic City, NJ (https://tidesandcurrents.noaa.gov/waterlevels.html?id=8534720)
Cape May, NJ (https://tidesandcurrents.noaa.gov/waterlevels.html?id=8536110)
Cape May, NJ meteorological data (https://tidesandcurrents.noaa.gov/met.html?id=8536110)