% Matlab script for Example 2: AEIC data
% Author: Matt Gardine, April 2009

% Step 1
dbname = '/Seis/catalogs/aeic/Total/aeic_2008';
db = dbopen(dbname,'r');

% Step 2
db_origin = dblookup(db,'','origin','','');
db_assoc = dblookup(db,'','assoc','','');

% Step 3
db = dbjoin(db_origin,db_assoc);

% Step 4
db = dbsubset(db,'ml>3 && sta=="COLA" && phase=~/P/');

% Step 5
[backazi,orid] = dbgetv(db,'seaz','orid');
dbclose(db);

% Step 6
rose(deg2rad(backazi))

% From here you can "pretty" up the plot by changing the 
% histogram bins, adding labels and a title, filling in
% the bins instead of plotting lines, etc.