Computational Methods of Scientific Programming. Matlab Lecture 4 Lecturers Thomas A Herring Chris Hill

Similar documents
Computational Methods of Scientific Programming Fall 2008

Computational Methods of Scientific Programming Fall 2007

Computational Methods of Scientific Programming. Matlab Lecture 3 Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming

Computational Methods of Scientific Programming Fall 2008

Computational Methods of Scientific Programming

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming Fall 2008

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

[1] CURVE FITTING WITH EXCEL

Plotting Graphs. Error Bars

An introduction to plotting data

Lab 3: Acceleration of Gravity

Modified Distribution Method

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Assignment 2. with (a) (10 pts) naive Gauss elimination, (b) (10 pts) Gauss with partial pivoting

Array Creation ENGR 1181 MATLAB 2

Part #10. AE0B17MTB Matlab. Miloslav Čapek Viktor Adler, Pavel Valtr, Filip Kozák

ENGR 1181 MATLAB 09: For Loops 2

Computational Methods of Scientific Programming

High Performance Computing: Tools and Applications

DataPro Quick Start Guide

Review for Quarter 3 Cumulative Test

Iterative Methods for Solving Linear Problems

EE 301 Signals & Systems I MATLAB Tutorial with Questions

Lecture (03) Arrays. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Spring 2018, HUM107 Introduction to Engineering

OPUS Projects Manager Training

Assignment: Backgrounding and Optical Flow.

Introduction to StatKey Getting Data Into StatKey

ACTIVITY 8. The Bouncing Ball. You ll Need. Name. Date. 1 CBR unit 1 TI-83 or TI-82 Graphing Calculator Ball (a racquet ball works well)

Matlab Tutorial: Basics

Table of Contents. Introduction.*.. 7. Part /: Getting Started With MATLAB 5. Chapter 1: Introducing MATLAB and Its Many Uses 7

Geology Geomath Estimating the coefficients of various Mathematical relationships in Geology

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

LOCAL GEODETIC HORIZON COORDINATES

MATLAB Control Software Bharat Balagopal, Bharathram Balasubramanian, and Eric Stratton Green

GUIDED NOTES 3.5 TRANSFORMATIONS OF FUNCTIONS

How to lay out a web page with CSS

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

MATLAB for Experimental Research. Fall 2018 Vectors, Matrices, Matrix Operations

18.02 Multivariable Calculus Fall 2007

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Convert Local Coordinate Systems to Standard Coordinate Systems

Introduction to MATLAB for Engineers, Third Edition

Documenting Your Design

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Getting Started with MATLAB

2

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

Writing MATLAB Programs

Introduction to GIS & Mapping: ArcGIS Desktop

Beginner s Mathematica Tutorial

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer.

ENGR/CS 101 CS Session Lecture 15

Grace days can not be used for this assignment

Date Course Name Instructor Name Student(s) Name WHERE WILL IT LAND?

Building a Graphical User Interface

Network Adjustment Program using MATLAB

Assignment 5: Collaborative Filtering

EOSC 352 MATLAB Review

MATLAB Lecture 1. Introduction to MATLAB

Introduction to MATLAB 7 for Engineers

This homework has an opportunity for substantial extra credit, which is described at the end of this document.

CHAPTER 6. The Normal Probability Distribution

MA 162: Finite Mathematics - Sections 2.6

Excel Boot Camp PIONEER TRAINING, INC.

MATLAB TUTORIAL WORKSHEET

EL2310 Scientific Programming

x = 12 x = 12 1x = 16

MATH Ms. Becker

ME 142 Engineering Computation I. Graphing with Excel

This is an almost-two week homework; it is almost twice as long as usual. You should complete the first half of it by October 2.

Pre-Algebra Class 9 - Graphing

Section G. POSITIONAL ACCURACY DEFINITIONS AND PROCEDURES Approved 3/12/02

Array Creation ENGR 1187 MATLAB 2

Experiment 1 CH Fall 2004 INTRODUCTION TO SPREADSHEETS

MATLAB 7 Getting Started Guide

Lab 4 Projectile Motion

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

`Three sides of a 500 square foot rectangle are fenced. Express the fence s length f as a function of height x.

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

Dealing with Data in Excel 2013/2016

Version 2.4 of Idiogrid

PART 1 PROGRAMMING WITH MATHLAB

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

Microsoft Excel Lab: Data Analysis

2

WEEK 4 REVIEW. Graphing Systems of Linear Inequalities (3.1)

Introduction to Matlab

LECTURE TWO Representations, Projections and Coordinates

Watershed Sciences 4930 & 6920 GEOGRAPHIC INFORMATION SYSTEMS

Excel 2. Module 3 Advanced Charts

Graphical Analysis of Data using Microsoft Excel [2016 Version]

ROSE-HULMAN INSTITUTE OF TECHNOLOGY

Creating an ArborCAD filter from Excel.

Graph Data Processing with MapReduce

Transcription:

12.010 Computational Methods of Scientific Programming Matlab Lecture 4 Lecturers Thomas A Herring Chris Hill

Review of Last Lecture Analysis of the some of the functions needed for the GUI development in Matlab Look at functions which would be appropriate for the GPS data analysis GUI Looked at how to use graphics objects 11/08/2011 12.010 Lec 17 2

Today s Lecture This is the last lecture on Matlab Analyze a complete GPS time series data analysis program Basic idea is to display position estimates as function of time and to work with these data Operations: De-trending (rate of change and breaks) Editing Implementation through a Graphical User Interface (GUI) 11/08/2011 12.010 Lec 17 3

Aims and Layout of program The GUI layout was designed using the Matlab guide tool. Basic features of GUI: Time series of GPS positions are stored in files which contain 3 header records and then time (in decimal years), position (north measured as distance from equator, east measured as distance from Greenwich meridian, Up as ellipsoidal height). Values in meters Uncertainty given as a standard deviation Since the positions are large numbers, the leading digits greater than 10 meters are removed from the values in the file. 11/08/2011 12.010 Lec 17 4

GUI Features GUI needs to be able to: Load data file Append another file to the loaded file (needed since the data file are separated into before and after a major earthquake in California: Hector mine Oct 17, 1999) Remove the linear trend from the data and possible jumps in the time series Edit the time series (both as individual points and a selected region of the data) Allows breaks when there appears to be jumps in the time series to be added Allow zoom of the plot so that break times can be set. 11/08/2011 12.010 Lec 17 5

GUI Features 02 Figures below shows the lay out the GUI from different versions of Matlab 11/08/2011 12.010 Lec 17 6

GUI Features 03 In MatLab code that implements the GUI is contained in the M-files, GPSanal.m and gpsgui.m. (These files are in the Matlab section of the web page). GPSanal.mat is also needed to initialize some variables (can be avoided) In the lecture, these M-files will be examined in detail. The features of the GUI are: Rather than listing file names, the names of the sites are extracted from file names and user selects a site and a component (North, East, Up) The file name is regenerated by re-concatenating the parts of the file name back together. 11/08/2011 12.010 Lec 17 7

GUI Features 04 Nearly all of the callbacks for the GUI use the gpsgui.m function M-file and a series of cases in a switch function. (This approach has the advantage on not requiring large number of M-files to implement the GUI.) Because functions forget there values between calls (unless global or persistence is used specifically save values), the gpsgui.m function saves the values needed in the UserData structure for each of the objects. Some of the handles are known when the GUI is called because the handles of the call back objects (gcbo) are available, but in other cases we need to find the object using the findobj function and a unique Tag added to each object. 11/08/2011 12.010 Lec 17 8

Algorithms needed The main algorithms needed by this GUI are: Least square fitting: We want to fit a function of the form pos(t) = pos(t o ) + vel*(t-t o ) + Sum(dpos i ) where pos(t) is position at time t, t o is a reference time (we use the mean time) vel is velocity dpos i are jumps in the time series at time given by the break times. We can write the above equation in matrix form by making pos(t) a vector and the quantities to be estimated another vector 11/08/2011 12.010 Lec 17 9

Algorithms 02 Defining another vector soln with entries soln = [pos(t o ) vel dpos 1 dpos 2... dpos n ] where n is the number of breaks Matrix form of equation is written as pos = A* soln where A is made up of rows that look like: A = [ 1 (t-t o ) 0 0 1] where the last group [0 0 1] depend on when the time of the measurement is with respect to the times of the breaks. The column value is 1 for all data times after the time of a break 11/08/2011 12.010 Lec 17 10

Solution to Least squares problem Solution to the above problem is given by soln = inv(a *A)*A *pos (see Detrend case in gpsgui.m) We also compute the root-mean-square (RMS) of the fit to the model using rms = sqrt(res *res/numdata) where res is the residual vector computed as the difference between the observed positions and the model estimate of the position, and numdata is the number of data. The rms of the residuals is used to estimate the standard deviation of the model parameter estimates. 11/08/2011 12.010 Lec 17 11

Analysis of GUI Run through the gpsgui function, examining the way that the call backs and the objects in the GUI interact. The main features to examine are: Use of UserData to save values Use of tags to name and find objects Use of button tool tips The sequence of using the GUI is to select a site and component (left hand sided options), Load the data, possibly select a continuation of the data and append it. Detrend and the edit, block edit, break, and zoom features allow detailed analysis of the data. 11/08/2011 12.010 Lec 17 12

Data access in GUI s Basic approaches are: Use persistent variables. Easiest but there are problems if multiple instances of the GUI are used Store the data (often as a structure) in the User Data part of the handle for a particular object. (This is method used examples) Use the getappdata, setappdata, rmappdata and isappdata to get data, set data (done first), remove data. Generally tag is used to find correct handle. Use guidata to save data in figure handle and retrieve data using data = guidata(gcbo); [graphic call back object). With this approach switchyard programming is not needed. 11/08/2011 12.010 Lec 17 13

Final GPS Analysis tool On the web page, under Matlab is also the final version of GPS analysis tool called tsview.m This tool has the GUI interface re-arranged and enhanced with new button and features. This version also explicitly accounts for screen size and has a ResizeFcn to correctly change the GUI when the window is re-sized. EasyGUI is a toolkit for making GUI s and is available from: http://www.mathworks.com/matlabcentral/fileexchange/22936 11/08/2011 12.010 Lec 17 14

Conclusions In general in using Matlab: Use the helpdesk and helpwin to find functions that could be useful Remember the basic features of the language in the way that arrays, structures and cells are defined Remember the range selection devices Remember the control structures Remember that functions forget their values (and handles can forget the UserData and Tags as well). Matlab is very powerful for quick and easily set up problems for analyses involving matrices. Homework #5 has been set and is due December 1, 2011 11/08/2011 12.010 Lec 17 15

MIT OpenCourseWare http://ocw.mit.edu 12.010 Computational Methods of Scientific Programming Fall 2011 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.