-
Notifications
You must be signed in to change notification settings - Fork 1
/
fourierPlot.m
executable file
·100 lines (86 loc) · 3.12 KB
/
fourierPlot.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
function [] = fourierPlot(PSI, t, k, num, mult, handle, mode)
% FourierPlot: Plots fourier modes of an AB/RW
% INPUT:
% PSI_k: Fourior transform of the spatiotemporal WF.
% t_k: time array
% num: number of modes to plot.
% mult: when used with talbot carpets. Just keep at 1.
% Set axes and extract data
cla(handle, 'reset');
axes(handle);
Nx = length(k);
if strcmp(mode, 'lines')
PSI_k = log(abs(fft(PSI.'))/Nx);
PSI_k = PSI_k.';
data = PSI_k(:, 1:mult:end); % Our data
% Plot
CO = lines(num);
LSO = {'-', '-.', '--'};
hData = cell(1,num);
legendInfo = cell(1,num);
for i = 1:num
hData{i} = plot(t, data(:, i), 'color', CO(i, :), 'LineStyle', LSO{floor(i/8)+1}, 'LineWidth', 1);
hold all;
end
for i=1:num
legendInfo{i} = sprintf('A_{%d}', mult*(i-1));
end
hLegend = legend(legendInfo);
set(hLegend, 'Location', 'BestOutside');
hXLabel = xlabel('$x$', 'Interpreter', 'latex');
hYLabel = ylabel('$\ln(|A_k|$)', 'Interpreter', 'latex');
set( gca , ...
'FontName' , 'Helvetica' );
set([hXLabel, hYLabel ], ...
'FontName' , 'Helvetica');
set([hXLabel, hYLabel ] , ...
'FontSize' , 10 );
set(gca, ...
'Box' , 'off' , ...
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'off' , ...
'YMinorTick' , 'off' , ...
'XGrid' , 'on' , ...
'YGrid' , 'on' , ...
'XColor' , [.3 .3 .3] , ...
'YColor' , [.3 .3 .3] , ...
'LineWidth' , 1 , ...
'YLim' , [-10, 2] ,...
'XLim' , [min(t), ceil(max(t))]);
elseif strcmp(mode, 'density')
Nx = size(PSI, 2);
PSI_k = fftshift(log(abs(fft(PSI.'))/Nx), 1);
PSI_k = PSI_k.';
tIntr = ceil(length(t)/1000);
surf(k, t(1:tIntr:end), PSI_k(1:tIntr:end, :), ...
'EdgeColor', 'none');
% Adjust misc plot components
colormap('Jet'); colorbar('eastoutside'); view([0 0 90]);
hXLabel = xlabel('k');
hYLabel = ylabel('t');
hZLabel = zlabel('log|A_k|');
%pk_max = max(max(PSI));
%pk_min = min(min(PSI));
%caxis([pk_min pk_max]);
set( gca , ...
'FontName' , 'Helvetica' );
set([hXLabel, hYLabel, hZLabel ], ...
'FontName' , 'Helvetica');
set([hXLabel, hYLabel, hZLabel ] , ...
'FontSize' , 10 );
set(gca, ...
'Box' , 'off' , ...
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'off' , ...
'YMinorTick' , 'off' , ...
'XGrid' , 'off' , ...
'YGrid' , 'off' , ...
'XColor' , [.3 .3 .3] , ...
'YColor' , [.3 .3 .3] , ...
'LineWidth' , 1 , ...
'XLim' , [-max(k) max(k)] ,...
'YLim' , [floor(min(t)) ceil(max(t))]);
end
end