Announcements | Syllabus | Schedule | Weekly lecture notes | Assignments | Links |

Today's lecture will focus on some tools that you can use to explore your dataset a little more closely.
Along the way, we will teach you two important concepts that we use heavily in data analysis.
First we will go over some syntax that will help you construct some special arrays very quickly.
Then we will introduce the *find* function in Matlab that helps you search for values in your data.
For the remaining class time, you will be able to use these tools to create several different kinds of plots in Matlab.

For the examples in this demo, we will refer to Yellowstone seismicity. At the end of 2008, Yellowstone National Park experienced an increase in seismic activity in the Yellowstone Lake area. We will take a look at this swarm of earthquakes, as well as others that have been recorded since 1973.
You can find out more about this swarm here.

You will need to download the text file that includes the earthquake data from here.

The columns in the text file are as follows:

`YEAR YYYYMMDDHHMMSS.SS LATITUDE LONGITUDE DEPTH MAGNITUDE`

Here is the link you want for Documentation

>> Years = [1973 1974 1975 1976 1977 1978 1979 ... 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ... 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009];Or, you can define a vector by using the following syntax:

Use it like this example:

>> Years = [1973:1:2009];But what if you don't know the minimum and maximum values to use? Here is how I might make my vector by using the

>> MinYear = min(ystone_eqs_sort(:,1)); >> MaxYear = max(ystone_eqs_sort(:,1)); >> Years = [MinYear:1:MaxYear];Even better, you can insert the

>> Years = [min(ystone_eqs_sort(:,1)):1:max(ystone_eqs_sort(:,1))];

>> ones(3) ans = 1 1 1 1 1 1 1 1 1

>> zeros(3) ans = 0 0 0 0 0 0 0 0 0To make arrays with

Example:

>> 17.2 .* ones(4,1) ans = 17.2 17.2 17.2 17.2

>> A=[1 5 0; 0 9 5] A = 1 5 0 0 9 5 >> tf = A > 5 tf = 0 0 0 0 1 0In the above example, tf is a new matrix filled with 1's and 0's. There is a 1 where the conditional of A > 5 was true, and 0 where it was false.

How about

>> tf = A >= 5 tf = 0 1 0 0 1 1or

>> tf = A < 5 tf = 1 0 1 1 0 0 >> tf = A == 5 tf = 0 1 0 0 0 1Note in the latter case, the use of the == to mean the test if they are equal and how that varies from the single = which is the assignment of the result to the tf variable. Let's go back to:

>> A A = 1 5 0 0 9 5 >> tf = A > 5 tf = 0 0 0 0 1 0Now here is where things get to be really neat:

>> locs = find(tf) locs = 4 >> A(locs) ans = 9Look at the MATLAB documentation for

Video example:

In case you forgot: the data are here: ystone_eqs_sort.txt

Let's find all the events that are in 2008:

>> tf=ystone_eqs_sort(:,1)==2008; >> locs=find(tf)Now let's plot them:

>> figure(1) >> clf >> plot(ystone_eqs_sort(:,4),ystone_eqs_sort(:,3), 'k.') >> hold on >> plot(ystone_eqs_sort(locs,4),ystone_eqs_sort(locs,3), 'ro') >> xlabel('longitude') >> ylabel('latitude') >> title('Yellowstone seismicity (2008 in red)')

A bit about

>> plot(ystone_eqs_sort(:,4),ystone_eqs_sort(:,3), 'k.') >> plot(ystone_eqs_sort(locs,4),ystone_eqs_sort(locs,3), 'ro')the second

Video example:

- Earthquake locations: color coded by year HINT: you may want to explore isolating individual years of peak activity
- Earthquake locations: color coded by depth
- Earthquake locations: color coded by magnitude
- Magnitude vs. depth
- Magnitude histogram
- 3D Earthquake locations: latitude/longitude/depth HINT: use the

These are not the only choices, so we encourage you to try things on your own.

Last modified: October 7, 2015