# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

## Loma Prieta Earthquake Analysis

This example shows how to analyze and visualize earthquake data.

The file quake.mat contains 200Hz data from the October 17, 1989 Loma Prieta earthquake in the Santa Cruz Mountains. The data are courtesy of Joel Yellin at the Charles F. Richter Seismological Laboratory, University of California, Santa Cruz.

whos e n v
Name          Size            Bytes  Class     Attributes  e         10001x1             80008  double                n         10001x1             80008  double                v         10001x1             80008  double

In the workspace there are three variables, containing time traces from an accelerometer located in the Natural Sciences building at UC Santa Cruz. The accelerometer recorded the main shock amplitude of the earthquake wave. The variables n, e, v refer to the three directional components measured by the instrument, which was aligned parallel to the fault, with its N direction pointing in the direction of Sacramento. The data are uncorrected for the response of the instrument.

Create a variable, t, containing the timestamps sampled at 200Hz with the same length as the other vectors. Represent the correct units with the seconds function and multiplication to achieve the Hz ( ) sampling rate. This results in a duration variable which is useful for representing elapsed time.

t = (1/200)*seconds(1:length(e))';
whos t
Name          Size            Bytes  Class       Attributes  t         10001x1             80010  duration

### Organize Data in Timetable

Separate variables can be organized in a table or timetable for more convenience. A timetable provides flexibility and functionality for working with time-stamped data. Create a timetable with the time and three acceleration variables and supply more meaningful variable names.

varNames = {'EastWest', 'NorthSouth', 'Vertical'};
quakeData = timetable(t, e, n, v, 'VariableNames', varNames)
quakeData =
Time       EastWest    NorthSouth    Vertical
__________    ________    __________    ________

0.005 sec        5           3             0
0.01 sec        5           3             0
0.015 sec        5           2             0
0.02 sec        5           2             0
0.025 sec        5           2             0
0.03 sec        5           2             0
0.035 sec        5           1             0
0.04 sec        5           1             0
0.045 sec        5           1             0
0.05 sec        5           0             0
0.055 sec        5           0             0
0.06 sec        5           0             0
0.065 sec        5           0             0
0.07 sec        5           0             0
0.075 sec        5           0             0
0.08 sec        5           0             0
0.085 sec        5           0             0
0.09 sec        5           0             0
0.095 sec        5           0             0
0.1 sec        5           0             0
0.105 sec        5           0             0
0.11 sec        5           0             0
0.115 sec        5           0             0
0.12 sec        5           0             0
0.125 sec        5           0             0
0.13 sec        5           0             0
0.135 sec        5           0             0
0.14 sec        5           0             0
0.145 sec        5           0             0
0.15 sec        5           0             0
0.155 sec        5           0             0
0.16 sec        5           0             0
0.165 sec        5           0             0
0.17 sec        5           0             0
0.175 sec        5           0             0
0.18 sec        5           0             0
0.185 sec        5           0             0
0.19 sec        5           0             0
0.195 sec        5           0             0
0.2 sec        5           0             0
0.205 sec        5           0             0
0.21 sec        5           0             0
0.215 sec        5           0             0
0.22 sec        5           0             0
0.225 sec        5           0            -1
0.23 sec        5           0            -1
0.235 sec        5           0            -1
0.24 sec        5           0            -2
0.245 sec        5           0            -2
0.25 sec        5           0            -2
0.255 sec        5           0            -2
0.26 sec        5           0            -3
0.265 sec        5           0            -3
0.27 sec        5           0            -3
0.275 sec        5           0            -4
0.28 sec        5           0            -4
0.285 sec        5           0            -4
0.29 sec        5           0            -5
0.295 sec        5           0            -5
0.3 sec        5           0            -5
0.305 sec        5           1            -6
0.31 sec        6           1            -7
0.315 sec        6           1            -7
0.32 sec        6           2            -8
0.325 sec        7           2            -9
0.33 sec        7           2            -9
0.335 sec        7           2           -10
0.34 sec        8           3           -10
0.345 sec        8           3           -11
0.35 sec        8           3           -12
0.355 sec        9           4           -12
0.36 sec        9           4           -13
0.365 sec        9           4           -13
0.37 sec        9           5           -14
0.375 sec       10           5           -15
0.38 sec       10           5           -14
0.385 sec       10           4           -12
0.39 sec       10           4           -11
0.395 sec       10           4           -10
0.4 sec       10           3            -9
0.405 sec       10           3            -8
0.41 sec       10           3            -7
0.415 sec       10           2            -6
0.42 sec       10           2            -5
0.425 sec       10           2            -4
0.43 sec       10           2            -3
0.435 sec       10           1            -2
0.44 sec       10           1            -1
0.445 sec       10           1             0
0.45 sec       10           0             1
0.455 sec       10           0             2
0.46 sec        9           0             2
0.465 sec        9           0             3
0.47 sec        9           0             4
0.475 sec        9           0             5
0.48 sec        8           0             6
0.485 sec        8           0             7
0.49 sec        8           0             8
0.495 sec        7           0             9
0.5 sec        7           0            10
0.505 sec        7           0            10
0.51 sec        6           0            10
0.515 sec        6           0            10
0.52 sec        6           0            10
0.525 sec        5           0            10
0.53 sec        5           0            10
0.535 sec        5           0            10
0.54 sec        5           0            10
0.545 sec        5           0            10
0.55 sec        5           0            10
0.555 sec        5           0            10
0.56 sec        5           0            10
0.565 sec        5           0            10
0.57 sec        5           0            10
0.575 sec        5           0            10
0.58 sec        5           0            10
0.585 sec        5           0            10
0.59 sec        5           0            10
0.595 sec        5           0            10
0.6 sec        5           0            10
0.605 sec        5           0            10
0.61 sec        5           0            10
0.615 sec        5           0            10
0.62 sec        5           0            10
0.625 sec        5           1            10
0.63 sec        5           1            10
0.635 sec        5           1            10
0.64 sec        5           2            10
0.645 sec        5           2            10
0.65 sec        5           2            10
0.655 sec        5           2            10
0.66 sec        5           3            10
0.665 sec        5           3             9
0.67 sec        5           3             9
0.675 sec        5           4             8
0.68 sec        5           4             7
0.685 sec        5           4             7
0.69 sec        5           5             6
0.695 sec        5           5             5

Explore the data by accessing the variables in the timetable with dot subscripting. (For more information on dot subscripting, see Access Data in a Table.) We chose "East-West" amplitude and plot it as function of the duration.

plot(quakeData.Time,quakeData.EastWest)
title('East-West Acceleration')

### Scale Data

Scale the data by the gravitational acceleration, or multiply each variable in the table by the constant. Since the variables are all of the same type (double), you can access all variables using the dimension name, Variables. Note that quake.Variables provides a direct way to modify the numerical values within the timetable.

quakeData.Variables = 0.098*quakeData.Variables;

### Select Subset of Data for Exploration

We are interested in the time region where the amplitude of the shockwave starts to increase from near zero to maximum levels. Visual inspection of the above plot shows that the time interval from 8 to 15 seconds is of interest. For better visualization we draw black lines at the selected time spots to draw attention to that interval. All subsequent calculations will involve this interval.

t1 = seconds(8)*[1;1];
t2 = seconds(15)*[1;1];
hold on
plot([t1 t2],ylim,'k','LineWidth',2)
hold off

### Store Data of Interest

Create another timetable with data in this interval. Use timerange to select the rows of interest.

tr = timerange(seconds(8),seconds(15));
dataOfInterest = quakeData(tr,:)
dataOfInterest =
Time       EastWest    NorthSouth    Vertical
__________    ________    __________    ________

8 sec     -0.098       2.254          5.88
8.005 sec          0       2.254         3.332
8.01 sec     -2.058       2.352        -0.392
8.015 sec     -4.018       2.352        -4.116
8.02 sec     -6.076        2.45        -7.742
8.025 sec     -8.036       2.548       -11.466
8.03 sec    -10.094       2.548          -9.8
8.035 sec     -8.232       2.646        -8.134
8.04 sec      -6.37       2.646        -6.566
8.045 sec     -4.508       2.744          -4.9
8.05 sec     -2.646       2.842        -3.234
8.055 sec     -0.784       2.842        -1.568
8.06 sec      1.078       2.548         0.098
8.065 sec       2.94       2.254         1.764
8.07 sec      4.802        1.96          3.43
8.075 sec      6.664       1.666         4.998
8.08 sec      5.488       1.372         6.664
8.085 sec      4.214       1.078         0.294
8.09 sec      3.038       0.784        -6.076
8.095 sec      1.764        0.49       -12.446
8.1 sec      0.588       0.196       -17.836
8.105 sec     -0.686      -0.098       -23.324
8.11 sec      -1.96      -0.392       -28.714
8.115 sec     -1.372      -0.686       -26.068
8.12 sec     -0.784       -0.98       -23.422
8.125 sec     -0.196      -1.274       -20.776
8.13 sec      0.392      -1.568       -18.228
8.135 sec       0.98       -1.96        -9.702
8.14 sec      1.568      -2.646        -1.176
8.145 sec      2.156       -3.43          7.35
8.15 sec      2.744      -4.214        15.876
8.155 sec      3.332        -4.9        24.402
8.16 sec       2.94      -5.684        20.188
8.165 sec      2.548      -6.468        15.974
8.17 sec      2.156      -7.154         11.76
8.175 sec      1.764      -6.272         7.546
8.18 sec      1.372      -5.292         3.332
8.185 sec       0.98       -4.41         0.784
8.19 sec      0.588       -3.43        -1.862
8.195 sec      0.196      -2.548         -4.41
8.2 sec     -0.196      -1.568        -6.958
8.205 sec      -0.49      -0.686        -9.604
8.21 sec     -0.882       0.196        -4.704
8.215 sec     -1.274       1.176         0.098
8.22 sec     -1.666       2.058         4.998
8.225 sec     -2.058       3.038           9.8
8.23 sec      -2.45        3.92          14.7
8.235 sec     -2.842         4.9        19.502
8.24 sec     -2.744       5.782        24.402
8.245 sec     -2.548       6.762        20.286
8.25 sec      -2.45       7.644         16.17
8.255 sec     -2.254        7.35        12.054
8.26 sec     -2.156       7.056         7.938
8.265 sec      -1.96       6.664         3.822
8.27 sec     -1.862        6.37        -2.842
8.275 sec     -1.666       6.076        -9.604
8.28 sec     -1.568       5.782       -16.268
8.285 sec     -1.372       5.586       -13.328
8.29 sec     -1.274        5.39        -10.29
8.295 sec     -1.078       5.194         -7.35
8.3 sec     -0.882       4.998         -4.41
8.305 sec     -0.784         4.9         -1.47
8.31 sec     -0.588       4.704         5.782
8.315 sec      -0.49       4.508        12.936
8.32 sec      0.392       4.312         20.09
8.325 sec      1.274       4.214        27.244
8.33 sec      2.156       4.018        21.364
8.335 sec      3.038       3.822        15.386
8.34 sec       3.92       3.234         9.506
8.345 sec      4.802       2.646         3.626
8.35 sec      3.626       2.058        -2.352
8.355 sec      2.352       1.568        -8.232
8.36 sec      1.176        0.98        -14.21
8.365 sec          0       1.078        -20.09
8.37 sec      -0.49       1.078       -16.464
8.375 sec      -0.98       1.176       -12.838
8.38 sec      -1.47       1.274        -9.212
8.385 sec      -1.96       1.372        -5.586
8.39 sec      -1.47        1.47         -1.96
8.395 sec      -0.98           0         0.588
8.4 sec      -0.49       -1.47         3.136
8.405 sec          0      -2.842         5.586
8.41 sec     -0.196      -4.312         8.134
8.415 sec     -0.294      -5.782         7.252
8.42 sec      -0.49      -7.154         6.468
8.425 sec     -0.686      -6.958         5.586
8.43 sec     -0.784      -6.664         4.802
8.435 sec      -0.98      -6.468         -1.47
8.44 sec     -0.784      -6.174        -7.644
8.445 sec      -0.49      -5.978       -13.916
8.45 sec     -0.294      -5.782        -20.09
8.455 sec     -0.098      -5.488       -16.268
8.46 sec      0.098      -5.292       -12.446
8.465 sec      0.294      -4.998        -8.624
8.47 sec       0.49      -4.802        -4.802
8.475 sec      0.686      -4.508         0.392
8.48 sec      0.882      -4.312         5.488
8.485 sec      1.176      -4.116        10.682
8.49 sec      1.372      -3.822        15.778
8.495 sec      1.568      -3.626         11.27
8.5 sec      1.764      -3.332         6.664
8.505 sec       1.96       -1.96         2.156
8.51 sec      2.156       -0.49        -2.352
8.515 sec      2.352        0.98       -10.192
8.52 sec      2.646       2.352       -17.934
8.525 sec      2.842        0.98       -25.676
8.53 sec      3.136       -0.49       -33.516
8.535 sec      3.332       -1.96        -28.42
8.54 sec      3.626      -3.332       -23.324
8.545 sec      3.822      -4.802       -18.228
8.55 sec      2.352      -4.312        -8.624
8.555 sec       0.98      -3.724          0.98
8.56 sec      -0.49      -3.234        10.486
8.565 sec      -1.96      -2.744         20.09
8.57 sec     -3.332      -2.254        29.694
8.575 sec     -1.666      -1.764        26.558
8.58 sec          0      -1.274         23.52
8.585 sec      1.666      -0.686        20.482
8.59 sec      3.332      -0.196        17.444
8.595 sec      3.234       0.294        14.308
8.6 sec      3.136       0.784          7.84
8.605 sec      3.038       1.274         1.372
8.61 sec      2.842       1.862        -5.194
8.615 sec      2.744       2.352       -11.662
8.62 sec      2.646       2.842       -18.228
8.625 sec      2.548       3.332       -13.524
8.63 sec      2.352       4.214         -8.82
8.635 sec      2.254       5.096        -4.116
8.64 sec      2.156       5.978         0.686
8.645 sec      2.058        6.86          5.39
8.65 sec       1.96       7.742        10.094
8.655 sec      1.764       8.624        14.014
8.66 sec      1.666       7.938        18.032
8.665 sec      1.568       7.154         22.05
8.67 sec       1.47       6.468        18.032
8.675 sec      1.176       5.782        14.112
8.68 sec      0.882       5.488        10.192
8.685 sec       0.49       5.194         6.174
8.69 sec      0.196         4.9        -2.842

Visualize the three acceleration variables on three separate axes.

figure
subplot(3,1,1)
plot(dataOfInterest.Time,dataOfInterest.EastWest)
ylabel('East-West')
title('Acceleration')
subplot(3,1,2)
plot(dataOfInterest.Time,dataOfInterest.NorthSouth)
ylabel('North-South')
subplot(3,1,3)
plot(dataOfInterest.Time,dataOfInterest.Vertical)
ylabel('Vertical')

### Calculate Summary Statistics

To display statistical information about the data we use the summary function.

summary(dataOfInterest)
RowTimes:    Time: 1400×1 duration        Values:            min          8 sec                  median       11.498 sec             max          14.995 sec             TimeStep     0.005 sec  Variables:    EastWest: 1400×1 double        Values:            min       -255.09               median     -0.098               max        244.51       NorthSouth: 1400×1 double        Values:            min       -198.55                 median      1.078                 max        204.33         Vertical: 1400×1 double        Values:            min       -157.88               median       0.98               max        134.46

Additional statistical information about the data can be calculated using varfun.This is useful for applying functions to each variable in a table or timetable. The function to apply is passed to varfun as a function handle. Below we apply the mean function to all three variables and output the result in format of a table, since the time is not meaningful after computing the temporal means.

mn = varfun(@mean,dataOfInterest,'OutputFormat','table')
mn =
mean_EastWest    mean_NorthSouth    mean_Vertical
_____________    _______________    _____________

0.9338           -0.10276           -0.52542

### Calculate Velocity and Position

To identify the speed of propagation of the shockwave, we integrate the accelerations once. We use cumulative sums along the time variable to get the velocity of the wave front.

edot = (1/200)*cumsum(dataOfInterest.EastWest);
edot = edot - mean(edot);

Below we perform the integration on all three variables to calculate the velocity. It is convenient to create a function and apply it to the variables in the timetable with varfun. In this example, we included the function at the end of this file and named it velFun.

vel = varfun(@velFun,dataOfInterest)
vel =
Time       velFun_EastWest    velFun_NorthSouth    velFun_Vertical
__________    _______________    _________________    _______________

8 sec      -0.56831           0.44642               1.8173
8.005 sec      -0.56831           0.45769                1.834
8.01 sec       -0.5786           0.46945                1.832
8.015 sec      -0.59869           0.48121               1.8114
8.02 sec      -0.62907           0.49346               1.7727
8.025 sec      -0.66925            0.5062               1.7154
8.03 sec      -0.71972           0.51894               1.6664
8.035 sec      -0.76088           0.53217               1.6257
8.04 sec      -0.79273            0.5454               1.5929
8.045 sec      -0.81527           0.55912               1.5684
8.05 sec       -0.8285           0.57333               1.5522
8.055 sec      -0.83242           0.58754               1.5444
8.06 sec      -0.82703           0.60028               1.5449
8.065 sec      -0.81233           0.61155               1.5537
8.07 sec      -0.78832           0.62135               1.5708
8.075 sec        -0.755           0.62968               1.5958
8.08 sec      -0.72756           0.63654               1.6291
8.085 sec      -0.70649           0.64193               1.6306
8.09 sec       -0.6913           0.64585               1.6002
8.095 sec      -0.68248            0.6483                1.538
8.1 sec      -0.67954           0.64928               1.4488
8.105 sec      -0.68297           0.64879               1.3322
8.11 sec      -0.69277           0.64683               1.1886
8.115 sec      -0.69963            0.6434               1.0583
8.12 sec      -0.70355            0.6385              0.94118
8.125 sec      -0.70453           0.63213               0.8373
8.13 sec      -0.70257           0.62429              0.74616
8.135 sec      -0.69767           0.61449              0.69765
8.14 sec      -0.68983           0.60126              0.69177
8.145 sec      -0.67905           0.58411              0.72852
8.15 sec      -0.66533           0.56304               0.8079
8.155 sec      -0.64867           0.53854              0.92991
8.16 sec      -0.63397           0.51012               1.0308
8.165 sec      -0.62123           0.47778               1.1107
8.17 sec      -0.61045           0.44201               1.1695
8.175 sec      -0.60163           0.41065               1.2072
8.18 sec      -0.59477           0.38419               1.2239
8.185 sec      -0.58987           0.36214               1.2278
8.19 sec      -0.58693           0.34499               1.2185
8.195 sec      -0.58595           0.33225               1.1965
8.2 sec      -0.58693           0.32441               1.1617
8.205 sec      -0.58938           0.32098               1.1137
8.21 sec      -0.59379           0.32196               1.0901
8.215 sec      -0.60016           0.32784               1.0906
8.22 sec      -0.60849           0.33813               1.1156
8.225 sec      -0.61878           0.35332               1.1646
8.23 sec      -0.63103           0.37292               1.2381
8.235 sec      -0.64524           0.39742               1.3356
8.24 sec      -0.65896           0.42633               1.4576
8.245 sec       -0.6717           0.46014               1.5591
8.25 sec      -0.68395           0.49836               1.6399
8.255 sec      -0.69522           0.53511               1.7002
8.26 sec        -0.706           0.57039               1.7399
8.265 sec       -0.7158           0.60371                1.759
8.27 sec      -0.72511           0.63556               1.7448
8.275 sec      -0.73344           0.66594               1.6968
8.28 sec      -0.74128           0.69485               1.6154
8.285 sec      -0.74814           0.72278               1.5488
8.29 sec      -0.75451           0.74973               1.4973
8.295 sec       -0.7599            0.7757               1.4606
8.3 sec      -0.76431           0.80069               1.4385
8.305 sec      -0.76823           0.82519               1.4312
8.31 sec      -0.77117           0.84871               1.4601
8.315 sec      -0.77362           0.87125               1.5248
8.32 sec      -0.77166           0.89281               1.6252
8.325 sec      -0.76529           0.91388               1.7614
8.33 sec      -0.75451           0.93397               1.8683
8.335 sec      -0.73932           0.95308               1.9452
8.34 sec      -0.71972           0.96925               1.9927
8.345 sec      -0.69571           0.98248               2.0108
8.35 sec      -0.67758           0.99277               1.9991
8.355 sec      -0.66582            1.0006               1.9579
8.36 sec      -0.65994            1.0055               1.8869
8.365 sec      -0.65994            1.0109               1.7864
8.37 sec      -0.66239            1.0163               1.7041
8.375 sec      -0.66729            1.0222               1.6399
8.38 sec      -0.67464            1.0285               1.5939
8.385 sec      -0.68444            1.0354               1.5659
8.39 sec      -0.69179            1.0428               1.5561
8.395 sec      -0.69669            1.0428               1.5591
8.4 sec      -0.69914            1.0354               1.5747
8.405 sec      -0.69914            1.0212               1.6027
8.41 sec      -0.70012           0.99963               1.6433
8.415 sec      -0.70159           0.97072               1.6796
8.42 sec      -0.70404           0.93495               1.7119
8.425 sec      -0.70747           0.90016               1.7399
8.43 sec      -0.71139           0.86684               1.7639
8.435 sec      -0.71629            0.8345               1.7565
8.44 sec      -0.72021           0.80363               1.7183
8.445 sec      -0.72266           0.77374               1.6487
8.45 sec      -0.72413           0.74483               1.5483
8.455 sec      -0.72462           0.71739               1.4669
8.46 sec      -0.72413           0.69093               1.4047
8.465 sec      -0.72266           0.66594               1.3616
8.47 sec      -0.72021           0.64193               1.3376
8.475 sec      -0.71678           0.61939               1.3395
8.48 sec      -0.71237           0.59783                1.367
8.485 sec      -0.70649           0.57725               1.4204
8.49 sec      -0.69963           0.55814               1.4993
8.495 sec      -0.69179           0.54001               1.5556
8.5 sec      -0.68297           0.52335                1.589
8.505 sec      -0.67317           0.51355               1.5997
8.51 sec      -0.66239            0.5111                1.588
8.515 sec      -0.65063             0.516                1.537
8.52 sec       -0.6374           0.52776               1.4473
8.525 sec      -0.62319           0.53266                1.319

Apply the same function velFun to the velocities to determine the position.

pos = varfun(@velFun,vel)
pos =
Time       velFun_velFun_EastWest    velFun_velFun_NorthSouth    velFun_velFun_Vertical
__________    ______________________    ________________________    ______________________

8 sec       2.1189                    -2.1793                    -3.0821
8.005 sec       2.1161                     -2.177                    -3.0729
8.01 sec       2.1132                    -2.1746                    -3.0638
8.015 sec       2.1102                    -2.1722                    -3.0547
8.02 sec        2.107                    -2.1698                    -3.0458
8.025 sec       2.1037                    -2.1672                    -3.0373
8.03 sec       2.1001                    -2.1646                    -3.0289
8.035 sec       2.0963                     -2.162                    -3.0208
8.04 sec       2.0923                    -2.1592                    -3.0128
8.045 sec       2.0883                    -2.1564                     -3.005
8.05 sec       2.0841                    -2.1536                    -2.9972
8.055 sec         2.08                    -2.1506                    -2.9895
8.06 sec       2.0758                    -2.1476                    -2.9818
8.065 sec       2.0718                    -2.1446                     -2.974
8.07 sec       2.0678                    -2.1415                    -2.9662
8.075 sec        2.064                    -2.1383                    -2.9582
8.08 sec       2.0604                    -2.1351                      -2.95
8.085 sec       2.0569                    -2.1319                    -2.9419
8.09 sec       2.0534                    -2.1287                    -2.9339
8.095 sec         2.05                    -2.1255                    -2.9262
8.1 sec       2.0466                    -2.1222                    -2.9189
8.105 sec       2.0432                     -2.119                    -2.9123
8.11 sec       2.0397                    -2.1157                    -2.9063
8.115 sec       2.0362                    -2.1125                    -2.9011
8.12 sec       2.0327                    -2.1093                    -2.8963
8.125 sec       2.0292                    -2.1062                    -2.8922
8.13 sec       2.0257                     -2.103                    -2.8884
8.135 sec       2.0222                       -2.1                    -2.8849
8.14 sec       2.0187                     -2.097                    -2.8815
8.145 sec       2.0153                     -2.094                    -2.8778
8.15 sec        2.012                    -2.0912                    -2.8738
8.155 sec       2.0088                    -2.0885                    -2.8692
8.16 sec       2.0056                     -2.086                     -2.864
8.165 sec       2.0025                    -2.0836                    -2.8584
8.17 sec       1.9994                    -2.0814                    -2.8526
8.175 sec       1.9964                    -2.0793                    -2.8466
8.18 sec       1.9935                    -2.0774                    -2.8404
8.185 sec       1.9905                    -2.0756                    -2.8343
8.19 sec       1.9876                    -2.0739                    -2.8282
8.195 sec       1.9846                    -2.0722                    -2.8222
8.2 sec       1.9817                    -2.0706                    -2.8164
8.205 sec       1.9788                     -2.069                    -2.8108
8.21 sec       1.9758                    -2.0674                    -2.8054
8.215 sec       1.9728                    -2.0657                    -2.7999
8.22 sec       1.9698                     -2.064                    -2.7944
8.225 sec       1.9667                    -2.0623                    -2.7885
8.23 sec       1.9635                    -2.0604                    -2.7824
8.235 sec       1.9603                    -2.0584                    -2.7757
8.24 sec        1.957                    -2.0563                    -2.7684
8.245 sec       1.9536                     -2.054                    -2.7606
8.25 sec       1.9502                    -2.0515                    -2.7524
8.255 sec       1.9467                    -2.0488                    -2.7439
8.26 sec       1.9432                     -2.046                    -2.7352
8.265 sec       1.9396                     -2.043                    -2.7264
8.27 sec        1.936                    -2.0398                    -2.7177
8.275 sec       1.9323                    -2.0365                    -2.7092
8.28 sec       1.9286                     -2.033                    -2.7011
8.285 sec       1.9249                    -2.0294                    -2.6934
8.29 sec       1.9211                    -2.0256                    -2.6859
8.295 sec       1.9173                    -2.0217                    -2.6786
8.3 sec       1.9135                    -2.0177                    -2.6714
8.305 sec       1.9096                    -2.0136                    -2.6642
8.31 sec       1.9058                    -2.0094                    -2.6569
8.315 sec       1.9019                     -2.005                    -2.6493
8.32 sec       1.8981                    -2.0005                    -2.6412
8.325 sec       1.8942                     -1.996                    -2.6324
8.33 sec       1.8905                    -1.9913                     -2.623
8.335 sec       1.8868                    -1.9865                    -2.6133
8.34 sec       1.8832                    -1.9817                    -2.6033
8.345 sec       1.8797                    -1.9768                    -2.5933
8.35 sec       1.8763                    -1.9718                    -2.5833
8.355 sec        1.873                    -1.9668                    -2.5735
8.36 sec       1.8697                    -1.9618                    -2.5641
8.365 sec       1.8664                    -1.9567                    -2.5551
8.37 sec       1.8631                    -1.9516                    -2.5466
8.375 sec       1.8597                    -1.9465                    -2.5384
8.38 sec       1.8564                    -1.9414                    -2.5304
8.385 sec       1.8529                    -1.9362                    -2.5226
8.39 sec       1.8495                     -1.931                    -2.5148
8.395 sec        1.846                    -1.9258                     -2.507
8.4 sec       1.8425                    -1.9206                    -2.4992
8.405 sec        1.839                    -1.9155                    -2.4912
8.41 sec       1.8355                    -1.9105                    -2.4829
8.415 sec        1.832                    -1.9057                    -2.4745
8.42 sec       1.8285                     -1.901                     -2.466
8.425 sec       1.8249                    -1.8965                    -2.4573

Notice how the variable names in the timetable created by varfun include the name of the function used. It is useful to track the operations that have been performed on the original data. Adjust the variable names back to their original values using dot notation.

pos.Properties.VariableNames = varNames;

Below we plot the 3 components of the velocity and position for the time interval of interest.

figure
subplot(2,1,1)
plot(vel.Time,vel.Variables)
legend(quakeData.Properties.VariableNames,'Location','NorthWest')
title('Velocity')
subplot(2,1,2)
plot(vel.Time,pos.Variables)
legend(quakeData.Properties.VariableNames,'Location','NorthWest')
title('Position')

### Visualize Trajectories

The trajectories can be plotted in 2D or 3D by using the component value. In the following we will show different ways of visualizing this data.

Begin with 2-dimensional projections. Here is the first with a few values of time annotated.

figure
plot(pos.NorthSouth,pos.Vertical)
xlabel('North-South')
ylabel('Vertical')
% Select locations and label
nt = ceil((max(pos.Time) - min(pos.Time))/6);
idx = find(fix(pos.Time/nt) == (pos.Time/nt))';
text(pos.NorthSouth(idx),pos.Vertical(idx),char(pos.Time(idx)))

Use plotmatrix to visualize a grid of scatter plots of all variables against one another and histograms of each variable on the diagonal. The output variable Ax, represents each axes in the grid and can be used to identify which axes to label using xlabel and ylabel.

figure
[S,Ax] = plotmatrix(pos.Variables);

for ii = 1:length(varNames)
xlabel(Ax(end,ii),varNames(ii))
ylabel(Ax(ii,1),varNames(ii))
end

Plot a 3-D view of the trajectory and plot a dot at every tenth position point. The spacing between dots indicates the velocity.

step = 10;
figure
plot3(pos.NorthSouth,pos.EastWest,pos.Vertical,'r')
hold on
plot3(pos.NorthSouth(1:step:end),pos.EastWest(1:step:end),pos.Vertical(1:step:end),'.')
hold off
box on
axis tight
xlabel('North-South')
ylabel('East-West')
zlabel('Vertical')
title('Position')

### Supporting Functions

Functions are defined below.

function y = velFun(x)
y = (1/200)*cumsum(x);
y = y - mean(y);
end