-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand_pulse.m
More file actions
72 lines (63 loc) · 1.83 KB
/
Copy pathrand_pulse.m
File metadata and controls
72 lines (63 loc) · 1.83 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [et, ew, tbp_rms] = rand_pulse(tbp, n)
%rand_pulse - returns a random pulse of a given time-bandwidth product
%
% Syntax: [et, ew, tbp_rms] = rand_pulse(tbp)
% [et, ew, tbp_rms] = rand_pulse(tbp, n)
%
% Inputs:
% tbp - Desired time-bandwidth product.
% n - (OPTIONAL) size of the 1xN array of the pulse. Function can choose
% and array size automatically.
%
% Outputs:
% et - complex electric field vs. time
% ew - complex electric field vs. frequency (FFT of Et)
% tbp_rms - root mean square time-bandwidth product. TBP +/- 5%
%
% Author: Justin Ratner
% Georgia Institute of Technology
% email address: jtratner@gatech.edu
% Website: http://frog.gatech.edu
% October 2011; Last revision: 05-Oct-2011
% REQUIREMENTS: calc_tbp.m, fftc.m, ifftc.m
debug = 1;
% choose the best n or take the user's input if available
n1 = 2^ceil(log2(32*(tbp/.5)^1));
if n1 > 16384
n1 = 16384;
end
if nargin == 1
n = n1;
end
tbp_rms = inf;
sig_t = 0;
sig_w = inf;
x = linspace(-1,1,n);
width_t = 0.6;
width_w = 0.6;
k = 1;
while abs(tbp_rms - tbp)/tbp > 0.05 || ...
abs(sig_t - sig_w)/sig_w > 0.05
envelope_t = exp(-2*log(2)*(x / width_t).^2);
envelope_w = exp(-2*log(2)*(x / width_w).^2);
et = rand(1, n) .* exp(i*2*pi*rand(1, n));
et = et .* envelope_t;
ew = fftc(et) .* envelope_w;
et = ifftc(ew);
[tbp_rms, sig_t, sig_w] = calc_tbp(et, ew);
if abs(tbp_rms - tbp)/tbp > 0.10
factor = 1 + sign(tbp - tbp_rms)*0.08;
width_t = width_t * factor;
width_w = width_w * factor;
end
if abs(sig_t - sig_w)/sig_w > 0.10
width_t = width_t * (1 + sign(sig_w - sig_t)*0.08);
end
k = k + 1;
if k > 1000
error('Error: could not generate a pulse for the given parameters.')
end
end
if debug
fprintf('k = %s \n', num2str(k))
end