Examples, examples: Outline

Similar documents
Data needs to be prepped for loading into matlab.

Getting started with Matlab: Outline

MATLAB An introductory tutorial

Excel 2. Module 3 Advanced Charts

Matlab Basics Lecture 3. Juha Kuortti November 6, 2017

Introduction to Minitab 1

Introduction to the workbook and spreadsheet

LAB 2: DATA FILTERING AND NOISE REDUCTION

LAB 2: DATA FILTERING AND NOISE REDUCTION

Using Excel for Graphical Analysis of Data

An introduction to plotting data

How To Test Your Code A CS 1371 Homework Guide

DISCOVERING THE NATURE OF PERIODIC DATA: II. ANALYZING DATA AND JUDGING THE GOODNESS OF FIT USING RESIDUALS

Lecture 1: MATLAB - advanced use cases

Using Excel for Graphical Analysis of Data

LAB 6: LOOP STATEMENTS

Experiment 1 CH Fall 2004 INTRODUCTION TO SPREADSHEETS

Math 1525: Lab 4 Spring 2002

Graphical Analysis of Data using Microsoft Excel [2016 Version]

Microscopic Measurement

Here is the data collected.

1 Introduction to Using Excel Spreadsheets

Starting a New Matlab m.file. Matlab m.files. Matlab m.file Editor/Debugger. The clear all Command. Our Program So Far

GRAPHS AND STATISTICS Residuals Common Core Standard

Chapter 2 Assignment (due Thursday, April 19)

Making Tables and Graphs with Excel. The Basics

A Basic Guide to Using Matlab in Econ 201FS

= 3 + (5*4) + (1/2)*(4/2)^2.

Programming. Dr Ben Dudson University of York

Sinusoidal Data Worksheet

Chapter 2 Assignment (due Thursday, October 5)

Exercise 3: Query, Visualize, and Edit Data Using ODM Tools

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Year Hourly $1.15 $1.30 $1.60 $2.20 $2.90 $3.10 $3.35

Dr Richard Greenaway

COMP : Practical 6 Buttons and First Script Instructions

Chapter 2: Linear Equations and Functions

Tips and Guidance for Analyzing Data. Executive Summary

Charts in Excel 2003

DATA PLOTTING WITH MATLAB

Math 121 Project 4: Graphs

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

Studying in the Sciences

General Program Description

Intro to Matlab for GEOL 1520: Ocean Circulation and Climate or, Notions for the Motions of the Oceans

MATLAB 1. Jeff Freymueller September 24, 2009

A. Using the data provided above, calculate the sampling variance and standard error for S for each week s data.

Error Analysis, Statistics and Graphing

The Interpolating Polynomial

STRAIGHT LINE GRAPHS THE COORDINATES OF A POINT. The coordinates of any point are written as an ordered pair (x, y)

Welcome to class! Put your Create Your Own Survey into the inbox. Sign into Edgenuity. Begin to work on the NC-Math I material.

USER's GUIDE for PLOT_FINDIF_1

Unit II Graphing Functions and Data

Fourier Transforms and Signal Analysis

ENV Laboratory 2: Graphing

Excel Manual X Axis Labels Below Chart 2010

Appendix C. Vernier Tutorial

Systems & Control Lab.-Manual

Navigating In Uncharted Waters Of Microsoft Excel Charts

0 Graphical Analysis Use of Excel

ENGR Fall Exam 1 PRACTICE EXAM

Data Analysis 1.2 Hoskins Lab Last Modified 03/29/2017 Chris DeCiantis

Introduction: EViews. Dr. Peerapat Wongchaiwat

ASSIGNMENT 3 Cobalt data T:\sys502\arcview\projects\Cobalt_2 T:\sys502\arcview\ projects\cobalt_2\cobalt_2.mxd T:\sys502\arcview\projects\Cobalt_2

MATH2070: LAB 3: Roots of Equations

GRETL FOR TODDLERS!! CONTENTS. 1. Access to the econometric software A new data set: An existent data set: 3

Dr. Iyad Jafar. Adapted from the publisher slides

MATLAB Examples. Interpolation and Curve Fitting. Hans-Petter Halvorsen

Lab 6: Graphical Methods

Here is Kellogg s custom menu for their core statistics class, which can be loaded by typing the do statement shown in the command window at the very

6 Using Technology Wisely

INTRODUCTION TO THE MATLAB APPLICATION DESIGNER EXERCISES

Math 1201 Unit 5: Relations & Functions. Ch. 5 Notes

Cumulus Main Window. The wind speed indicator shows three values:

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Ingredients of Change: Nonlinear Models

Graphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):

Lecture 8. Divided Differences,Least-Squares Approximations. Ceng375 Numerical Computations at December 9, 2010

Scripting Tutorial - Lesson 2

GRAPHING BAYOUSIDE CLASSROOM DATA

Requirements Analysis (big part of Software Engineering) defines. Audience. Purpose. Constraints (e.g. download time limits, browsers to support)

Correlation. January 12, 2019

CS 221 Lecture. Tuesday, 13 September 2011

Introduction to Matlab

MPhil computer package lesson: getting started with Eviews

Patterning Math Lab 4a

NaN is used several ways in MATLAB. Working with NaN requires some attention to detail. Missing data Result of some computations...

LAB #1: DESCRIPTIVE STATISTICS WITH R

Graphing and Equations

ECE-205 Lab 1. Introduction to Simulink and Matlab

Information for Candidates. Test Format

Number of Regions An Introduction to the TI-Nspire CAS Student Worksheet Created by Melissa Sutherland, State University of New York at Geneseo

Using Kingdom Suite for 3D Horizon/Fault Interpretation Parts 3 & 4 - Horizon Interpretation and Correlation

Homework 1 Excel Basics

Chemistry Excel. Microsoft 2007

=.1( sin(2πx/24) y) y(0) = 70.

3.1 Graphing Relationships

Chapter 4 Graphing Linear Equations and Functions

Flow Control and Functions

How to use the SATURN Observation Network: Endurance Stations Site: Table of Contents

Transcription:

Examples, examples: Outline Overview of todays exercises Basic scripting Importing data Working with temporal data Working with missing data Interpolation in 1D Some time series analysis Linear regression Getting started Preparing data Data analysis

Exercise Overview Today we are going to be doing lots of exercises. Today's dataset consists of 2001 hourly buoy measurements from a buoy near Bodega Bay (#46013): http://www.ndbc.noaa.gov/maps/monterey_bay.shtml Today we will: Import the data Learn how matlab deals with dates and times Deal with missing data Fill in missing data Do some autocorrelations of wind and air temperature Do a linear fit between wind and air temperature

Basic Scripting Matlab commands can be stored in a text file with a.m extension and then run using the filename. Change the working directory to your student directory (z:\home\wfcb\wfcb??\). Use the edit command to being editing a text file.» edit Put some commands in the file and save it as myfile.m: a = 1:10; plot( a, a.^2 ) Run your commands by either hitting F5 or typing from the command line:» myfile Get in the habit of saving commands in m files.

Importing data The data for this class is located in: z:\pkg\wfcb\class3\46013h2001.txt Take a look at data (use edit). There are many ways to get data into matlab. One popular way is through the Excel toolbox. Many other commands: load, importdata, textread, imread (try: help fileformats) We have used load. Drawback: Requires rigid format. Another more flexible command is importdata. More flexible tries to load data no matter what Works on lots of different formats (text, images, HDF,...) Exercise: Use importdata to load todays dataset. Next slide explains the result of loading data.

Structures The result of loading a text file with importdata is often a structure. Many functions return structures. Structures are like bags of variables. If you have loaded the data into a variable a, then the column names would be accessed using:» a.colheaders Structures are a convenient way to keep together related variables. Add an element to a structure like so:» a.buoy_num = 46013 Take a look at the elements of the result of importdata. Which element contains the numerical data?

Temporal data The first four columns of the data are year, month, day and hour Matlab has its own way of dealing with dates and times Numbers days from Year 0, January 1 at 00:00! Noon on January 1, 2000 is 730486.5 to matlab. Matlab has functions to convert to and from matlab format: datenum: converts year, month,... to matlab date numbers datevec: converts numbers to individual parts datestr: converts numbers to human readable dates datetick: converts numeric ticks on a plot to dates Exercises: Put dataset dates in matlab format (datenum) Oops dateset dates are in GMT (subtract 8 hours for PST) Plot PST date vs. air temp (ATMP) and fix x axis labels (datetick)

Initial plot of air temperature Looks pretty bad air temperatures of 1000ºC are still unusual. Why does it look this way? Try scaling y axis limits to something more reasonable (ylim)

Missing Data The problem in the last plot is missing data In this dataset, 99, 999 and 9999 all indicate missing data. Exercises: Create a new variable of data with all missing data replaced by NaN. Use logical operations (last class) to do this. == is equivalent is logical or Replot data

Plot of air temperature with NaNs Try zooming in on the second half of March. Hint: Use datetick('keeplimits') to create date ticks after zoom. Do you see any data gaps? What dates?

Interpolation in 1D We want to fill in all that missing data using linear interpolation. Exercise: Use the interp1 function to fill in the missing data for air temperature and water temperature (WTMP). Hints: You will need to create new variables with the results. Use isnan to remove bad data (remember ~ is logical not). Use interp1 to get values at all points. Where data already exists, it will return the same value; elsewhere, it will interpolate.

Replot data Exercises: Plot air temperature and water temperature on a figure with different line colors. Put a black circle around all data points that were interpolated (i.e. originally missing data). Hint: use isnan and look at line styles in help plot. Don't forget to hold on to your first plot. Zoom in on second half of March again Can you figure out how to fill in the dots? Don't worry if you can't do this.

Time Series Analysis: Autocorrelations Now we want to look first at how water and air temperatures vary in time through autocorrelations. Autocorrelations are a measure of how well data at one point in time reflects data at a future or past point in time. It is basically a lagged correlation. Exercises: Compute the autocorrelations for air and water temp (hint: use the xcov and set the scaling option to 'coeff'). Plot both autocorrelation functions on the same graph. Label x and y axes. Remember that lags are in hours. Zoom in to a sensible time period (i.e. a few days). What does the slower decline of one of the autocorrelations means? What do the oscillations in the curves mean?

Plot of autocorrelations Slower decline of water temp autocorrelation means that it is more stable. Oscillations every 24 hours mean that temps have a diurnal cycle, but air temp fluctuates more.

Linear Regression Exercise: Make a scatter plot of air temperature against water temperature using the plot function. Clearly there is a relationship. Matlab can do basic linear regression with polyfit (more robust fits need Stats Toolbox or code available online). Exercises: Use polyfit to regress air temp vs. water temp. Add a red line to your scatter plot with the linear fit using the polyval function. Can you plot the residuals of the fit?

Next Class For next class, we will continue working with this dataset. Also, think about datasets and analyses that you could bring into the class and we could work on. Must be general enough that everyone can get involved. Must not be too complex for us to work through it in a class. I will choose one or two to work on.