This program demonstrates how
to set up a push button menu, how to define time series, and pick points
from an existing graph with the mouse.
|
|
|
| function pswaves(action)
%function pswaves % pswaves - compute P and S wavefronts, examine particle motions % % Input: % vp - P wave velocity % vs - S wave velocity % boxsize - size of box containing source (km) % source is at the center % time - travel time of the wave(s) % % C.A. Langston 9/19/99 % modified 3/20/01 to represent a vertical (+y) point force % global ui_v1t ui_v2t ui_b1t ui_t1t global f1 f2 f3 global lenp lens if nargin < 1; action = 'initialize'; end; if strcmp(action,'initialize') %----------Create Initialization input window ------------------- f1=figure('position',[10 170 280 230],'name','Parameter Input');
ui_v1=uicontrol('style','pushbutton','position', ...
ui_v2=uicontrol('style','pushbutton','position', ...
ui_b1=uicontrol('style','pushbutton','position', ...
ui_t1=uicontrol('style','pushbutton','position', ...
ui_calc=uicontrol('style','pushbutton','position', ...
elseif strcmp(action,'wavepict') f2=figure('name','Wavefront Diagram');
elseif strcmp(action,'wavepick') %
f3=figure('name','Particle Motions for Wave Pick'); t=linspace(0,3,50);
plot(t,fy,'b',t,fx,'r');
end;
|
Define the function. "action" is a text string which controls
what part of
of the program is used at a time. This part can be seen using "help" pswaves while in the Matlab command window. equivalent to a fortran common block, needed to save variables values
Make the first interactive menu
define pushbuttons
"callback" sends everything back to the beginning to do something else.
Construct the wavefront diagram
Define circular wavefronts and plot them.
"callback" to setup picking points on each wavefront.
"ginput(1)" takes one point from the plot after a mouse button is pushed.
Make a simple time function to represent the wavefront.
Plot the displacements in another figure.
|
Here is the input pushbutton
interface with parameters that have been input:
Here is the wavefront diagram with the process of interactively picking a point on the P wavefront:
Here are resulting P wave motions from this point:
Matlab WebSite: http://www.mathworks.com/