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

>> 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:

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: September 29, 2011