-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_PlotWave.m
More file actions
49 lines (47 loc) · 1.58 KB
/
Copy pathFun_PlotWave.m
File metadata and controls
49 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function Fun_PlotWave(Sortob, da1, srate,scale)
% =========================================================================
% Plot strong-motion waveforms sorted by epicentral distance
% The function assumes that each column is one waveform component.
% =========================================================================
if nargin < 3 || isempty(srate)
srate = 4;
end
% Check data dimensions
[numberOfSamples, numberOfChannels] = size(Sortob);
da1 = da1(:);
if numel(da1) ~= numberOfChannels
error(['The length of da1 must equal the number of columns ', ...
'in sortedObservedData.']);
end
% Time vector
time = (0:numberOfSamples - 1)' ./ srate;
% Use the distance vector as vertical positions.
dist = da1;
% Scale waveforms so that neighboring traces do not overlap excessively.
figure('Color', 'w');
hold on;
box off;
% Plot each waveform at its corresponding epicentral distance
cols=slanCM('viridis',ceil(length(da1)/3));
k=1;
for iChannel = 1:numberOfChannels
if mod(iChannel,3)==0
waveform = Sortob(:, iChannel);
% Remove the mean only for display.
waveform = waveform - mean(waveform, 'omitnan');
plottedWaveform = dist(iChannel) + scale .* waveform;
plot(time, plottedWaveform, ...
'k-','LineWidth', 0.3,'Color',cols(k,:));
k=k+1;
end
end
xlabel('Time (s)');
ylabel('Epicentral distance (km)');
set(gca, ...
'FontName', 'Times New Roman', ...
'FontSize', 18, ...
'TickDir', 'out','linewidth',0.8,'YDir', 'reverse');
axis('tight');
set(gcf,'position',[200,50,1000,800]);
hold off;
end