Seismogram Calculation Program

Seismogram Calculation program

Updated 08/12/04

The following program was the initial program written to generate the amplitude files. It asks for a distance to the epicenter and the magnitude of the earthquake and then generates the data for one graph and prints it to a file. This program assumes 100 Hz data and uses a different algorithm to generate the variety and noise in earthquake waves. Students could compare these functions with those in the other program.


% Program to plot a simple seismogram
% M and dist to be input commands

clear

M=input('What magnitude for the quake? ');
dist=input('Distance from epicenter? ');

tdiff=dist/8;
ttot=tdiff+1+20;

% Gives amp in mm

amp=10^(M+2.92-3*(log10(dist)))

tp=1.01:0.01:tdiff+1.01;
xp=0.7*exp(-.05*tp) .*sin(2*pi*0.8*tp);
rp=0.3*exp(-.01*tp) .*sin((2*pi*3*tp)+ rand);
yp=(amp/5)*(xp+rp);


ts=tdiff+1.02:0.01:ttot;
txp=0:0.01:(ttot-tdiff-1.02);
xs=0.7*exp(-.02*txp) .*sin(2*pi*0.6*ts);
rs=0.3*exp(-.01*txp) .*sin((2*pi*2*ts)+ rand);
ys=(amp)*(xs+rs);

tn=0.0:0.01:1.0;
yn=(amp/500)*randn(size(tn));

t=0:0.01:ttot;
y=zeros(size(t));

y(1:101)=yn;
y(102:(length(tp)+101))=yp;
y((length(tp)+102):length(t))=ys;

plot(t,y);

fid=fopen('test1.dat','w');
fprintf(fid,'%3.4f\n',y);
fclose(fid);