a= 'Plot PAS acceleration data for 3 components (original)'

clear
close

load pas_ud;
size(pas_ud)
load pas_ns;
size(pas_ns)
load pas_ew;
size(pas_ew)

delt=0.01;
t = 0.0:delt:(9998*delt);
t = t';
yrange=[-700,700];
ax=[0,100,yrange];
subplot(3,1,1), plot(t,pas_ud), axis(ax)
 title('pas_ud'), ylabel('acceleration')
subplot(3,1,2), plot(t,pas_ns), axis(ax)
 title('pas_ns'), ylabel('acceleration')
subplot(3,1,3), plot(t,pas_ew), axis(ax)
 title('pas_ew'), ylabel('acceleration')
xlabel('time (sec)')

a='Click twice with the mouse on the screen to select a time interval'

t1=ginput(1);
t1(2)=t1(1);
subplot(3,1,1), hold on, plot(t1,yrange,'r-')
subplot(3,1,2), hold on, plot(t1,yrange,'r-')
subplot(3,1,3), hold on, plot(t1,yrange,'r-')

t2=ginput(1);
t2(2)=t2(1);
subplot(3,1,1), hold on, plot(t2,yrange,'r-')
subplot(3,1,2), hold on, plot(t2,yrange,'r-')
subplot(3,1,3), hold on, plot(t2,yrange,'r-')

print p1.ps
a='save in p1.ps'
a='Enter Return'
pause

a='Zoom in on the selected time interval'
trange=sort([t1(1),t2(1)])
k=find((trange(1)<=t) & (t<=trange(2)));
ud=pas_ud(k);
ns=pas_ns(k);
ew=pas_ew(k);
t=t(k);
ax=[trange,yrange];
subplot(3,1,1), plot(t,ud), axis(ax)
 title('pas_ud'), ylabel('acceleration')
subplot(3,1,2), plot(t,ns), axis(ax)
 title('pas_ns'), ylabel('acceleration')
subplot(3,1,3), plot(t,ew), axis(ax)
 title('pas_ew'), ylabel('acceleration')
xlabel('time (sec)')

print p2.ps
a='save in p2.ps'
a='Enter Return'
pause

a='The velocity and displacement'
ndot=cumsum(ns)*delt; ndot=ndot-mean(ndot);
vdot=cumsum(ud)*delt; vdot=vdot-mean(vdot);
edot=cumsum(ew)*delt; edot=edot-mean(edot);
subplot(2,1,1); plot(t,[ndot+500,vdot,edot-500])
axis([trange,min(edot-500)-200,max(ndot+500)+200])
xlabel('Time (sec)'), ylabel('WE-DU-SN'), title('Velocity')
drawnow

ndos=cumsum(ndot)*delt; ndos=ndos-mean(ndos);
vdos=cumsum(vdot)*delt; vdos=vdos-mean(vdos);
edos=cumsum(edot)*delt; edos=edos-mean(edos);
subplot(2,1,2); plot(t,[ndos+1000,vdos,edos-1000])
axis([trange,min(edos-1000)-200,max(ndos+1000)+200])
xlabel('Time (sec)'), ylabel('WE-DU-SN'), title('Displacement')

print p3.ps
a='save in p3.ps'
a='Enter Return'
pause

a='Trajectory of the displacement'
subplot(2,2,1), plot(ndos,vdos,'y-');
axis([-500,500,-500,500]), xlabel('S-N'), ylabel('D-U')
n=size(t)
for j=1:1000:n(1)
  text(ndos(j),vdos(j),['* ',int2str(t(j))])
end
a='Enter Return'
pause

subplot(2,2,2), plot(edos,vdos,'m-');
axis([-500,500,-500,500]), xlabel('W-E'), ylabel('D-U')
for j=1:1000:n(1)
  text(edos(j),vdos(j),['* ',int2str(t(j))])
end

subplot(2,2,3), plot(ndos,edos,'c-');
axis([-500,500,-500,500]), xlabel('S-N'), ylabel('W-E')
for j=1:1000:n(1)
  text(ndos(j),edos(j),['* ',int2str(t(j))])
end
a='Enter Return'
pause

a='3-D trajectory of the displacement'
subplot(2,2,4), plot3(ndos,edos,vdos,'r-');
axis([-400,400,-400,400,-400,400])
xlabel('S-N'), ylabel('W-E'), zlabel('D-U')
for j=1:1000:n(1)
  text(ndos(j),edos(j),vdos(j),['* ',int2str(t(j))])
end
set(gca,'box','on')

print p4.ps
a='save in p4.ps'
a='Enter Return'
pause

a='Large 3-D trajectory of the displacement'
subplot(1,1,1)
plot3(ndos,edos,vdos,'r');
axis([-400,400,-400,400,-400,400])
set(gca,'box','on')
xlabel('S-N'), ylabel('W-E'), zlabel('D-U'),title('3D displacement')
for j=1:1000:n(1)
  text(ndos(j),edos(j),vdos(j),['* ',int2str(t(j))])
end
hold on
plt=plot3(0,0,0,'.','erasemode','xor','markersize',24);
dk=ceil(length(edos)/1500);
for k=1:dk:length(edos)
  set(plt,'xdata',ndos(k),'ydata',edos(k),'zdata',vdos(k))
  drawnow
end
hold off
s='for k=1:dk:length(edos)';
s=[s,'set(plt,''xdata'',ndos(k),''ydata'',edos(k),''zdata'',vdos(k)),'];
s=[s,'drawnow,end'];
echo off

print p5.ps
a='save in p5.ps'





