Skip to main content
U.S. flag

An official website of the United States government

strainz17: Earthquake Strains and Rotations

March 7, 2019

Strainz17.m is a MATLAB-language function for deriving the best-fitting uniform strain tensor and rigid body rotation as functions of time, based on ground displacement or velocity recordings made on an array of sensors. Strainz17.m implements the theory in Spudich et al. (J. Geophys. Res., 1995) and Spudich and Fletcher (Bull. Seismol. Soc. Am., 2008). In addition to the strainz1717.m function, the downloadable file provides sample input and output data, and it provides functions for running the sample test cases.

Author: Paul Spudich
Usage: Calculate strains and rotations of an array
Platform: Any platform running MATLAB
Interface: MATLAB command line
Input: Seismograms from several stations, via function’s calling arguments
Output: .txt, .mat, and .pdf files
Examples: Contained in downloadable file
Download: See online documentation

We present Matlab®-language software that implements the method of Spudich et al. (1995) and Spudich and Fletcher (2008) to calculate the best fitting uniform strain and rigid-body rotation time series and their formal errors, given array measurements of ground motions. This example includes example input, example output, and a script for running the example.

Download strainz17 ZIP file (700 Kb)

Compressed file containing 21 files. This file may be uncompressed on a Windows machine using PKUNZIP, WinZip, or other software. On a Mac this file can be uncompressed using StuffIt Expander or other software. On linux/unix the file may be uncompressed using the unzip command.

Contents of the zip file:

  • strainz17.m - Matlab language function for calculation of strain, rotation, and their errors from array data. This function takes its input and output through data structures. The exact definition of the input and output structures is described in the comments of the m-file.
  • RUN_THE_EXAMPLE.m - Matlab script that runs the example.
  • make_example_in_structure.m - Matlab function that reads the stn*.txt files and builds the structure input to strainz17.m.
  • plot_save_strainz_output1.m - Matlab function that extracts, plots, and saves the results of the strainz17 calculation.
  • stn1.txt, stn2.txt, ... stn14.txt - ascii text files, each of which contains an example three-component ground displacement time series from one station of a 14-station seismic array.
  • our_example_ascii_output.txt - an ascii text file containing the rotation and strain time series that we obtain when we run the example.
  • our_example_strainz_output1.mat - a Matlab '.mat' file containing the full results that we obtain when we run the example.
  • our_example_strainz_output1.pdf - a pdf file containing the example plotted output.

Comments on the Example

This example has four goals: 1) to verify that when you run strainz17, you obtain the same results that we obtain with the same input, 2) to show how to set up the input variables for the case in which the analysis is done for a 10-station subarray of a 14-station array, 3) to show the Matlab novice user how to take seismograms from ascii data files and place them into the input structure that strainz17 requires, and 4) to show the Matlab novice how to extract, plot, and save numerical output from the strainz17 output structure. The function make_example_in_structure.m is aimed at goal 3, and the function plot_save_strainz_output1.m is aimed at goal 4. Both of these functions are not intended to be general input or output routines. Instead, they are written to be simple and easily understandable.

The time series of the example are not real seismograms.

Running the Example

To run this example, uncompress the zip file. A folder/directory named example17a should be created. Make that directory your current/working directory while in the Matlab environment. At the Matlab '>>' prompt, invoke the script by typing RUN_THE_EXAMPLE, and if all goes well you will see the following:

>> RUN_THE_EXAMPLE Vp = 1.9300 Vs = 0.3260 Reading data from file stn1.txt Reading data from file stn2.txt Reading data from file stn3.txt Reading data from file stn4.txt Reading data from file stn5.txt Reading data from file stn6.txt Reading data from file stn7.txt Reading data from file stn8.txt Reading data from file stn9.txt Reading data from file stn10.txt Reading data from file stn11.txt Reading data from file stn12.txt Reading data from file stn13.txt Reading data from file stn14.txt In strainz17, matrix condition number = 5.3522 Saving plot in file plot_save_strainz_output1.pdf Saving numerical results in file plot_save_strainz_output1.mat Saving numerical results in ascii file ascii_output.txt

The example creates a plot on the screen and three output files:

  1. plot_save_strainz_output1.pdf - a pdf version of the figure on the monitor.
  2. plot_save_strainz_output1.mat - a Matlab '.mat' file containing the complete numerical output of strainz17 in full precision. See the strainz17.m comments for a detailed description of the output. The file plot_save_strainz_output1.mat contains a structure name szo which can be compared with the identically-named structure in our output file our_example_strainz_output.mat, included in the zip file. Your results should agree with ours to 13 or 14 significant figures.
  3. ascii_output.txt - an ascii file containing a subset of the rotation and strain time series printed to limited precision. This file should agree exactly with our output file our_example_ascii_output.txt included in the zip file. Row/record i of ascii_output.txt contains:

Column 1: t(i), an artificial example time assigned to row i
Column 2: maximum shear strain at time t(i)
Column 3: dilatation at time t(i)
Column 4: rotation (rad) about the x1 axis at time t(i)
Column 5: rotation (rad) about the x2 axis at time t(i)
Column 6: rotation (rad) about the x3 axis at time t(i)
Column 7: mistfit ratio at time t(i)

Development Environment and Warning About Line Ends

The distributed files were created on an Apple Macintosh computer runing OS X version 10.5.5 using Matlab Version R2008a. ASCII files on the Mac (e.g. *.m, *.txt) use the newline character as the line/record terminator. PCs use carriage-return newline. If our text files do not wrap text properly on your computer, you might need to replace our line-end characters with yours.


  • Spudich, P., Steck, L.K., Hellweg, M., Fletcher, J., and Baker, L.M., 1995, Transient stresses at Parkfield, California, produced by the M7.4 Landers earthquake of June 28, 1992: observations from the UPSAR dense seismograph array: J. Geophys. Res. , v. 100, 675-690. doi:10.1029/94JB02477
  • Spudich, P., and Fletcher, J., 2008. Observation and prediction of dynamic ground strains, tilts and torsions caused by the M6.0 2004 Parkfield, California, earthquake and aftershocks, derived from UPSAR array observations: Bull. Seismol. Soc. Am. , 98, 1898 – 1914. DOI: 10.1785/0120070157
Publication Year 2019
Title strainz17: Earthquake Strains and Rotations
Product Type Software Release
Record Source USGS Digital Object Identifier Catalog