-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdispersion.m
66 lines (39 loc) · 1.3 KB
/
dispersion.m
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function y = dispersion(signal,distance, dt, varargin)
global f_cutt % cut-off frequency
% signal should be of even length
% check if a non-default file name is used for dispersion relation
for i = 1:2:length(varargin)
if strcmp(varargin{i},'disp_curv_file')%varargin{i}=={'disp_curv_file'}
file = char(varargin(i+1));
break
end
end
% dt = 3.300000e-7;
N = length(signal);
% checking: signal should be of even length
if mod(N,2)==1
error ('signal should have even length');
end
f_cut_off = f_cutt;
x1 = signal;
% find fft
yp = fft(x1);
yp = yp(1:length(x1)/2+1);
f = (0:1/length(x1):1/2)/dt; % frequencies
% Load the dispersion relation file
if exist('file','var')==0
load('dispersion.mat');
else
load(file)
end
% Calculate delay time for each frequency
Delay_time=distance./Cn;
% Apply low pass filter
yp = (f<f_cut_off).* yp;
% Use fourier shifting theorem
yp = yp.*exp(-1i*2*pi*f.*Delay_time);
% Calculate the conjugates and append
yp = [yp conj(fliplr(yp(2:end-1)))];
% Calculate ifft assuming the signal is symmetric
y = ifft(yp,'symmetric');
end