-
Notifications
You must be signed in to change notification settings - Fork 1
/
nlsePlot.m
executable file
·72 lines (65 loc) · 2.49 KB
/
nlsePlot.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
function nlsePlot(PSI, x, t, tIntr, xIntr, handle, mode)
% densityPlot: used to plot flat density maps of RWs and ABs.
% Input: PSI: this is the matrix with the data points. Note that it can't
% be complex, if you are interested in plotting intensity then
% input abs(PSI.^2) when calling the function.
% x: x-array
% t: y-axis array, usually time.
% tIntr: how many points to sample from t-array.
% xIntr: how many points to sample from x-array.
% handle: handle to the axes where you want to plot it. If you are
% using this function manually, you can use h=axes();
% and pass h.
% Set current axes
axes(handle);
delete(handle.Children);
% Plot
switch lower(mode)
case 'density'
surf(x(1:xIntr:end), t(1:tIntr:end), PSI(1:tIntr:end, 1:xIntr:end), ...
'EdgeColor', 'none');
% Adjust misc plot components
colormap('Jet'); colorbar('eastoutside'); view([0 0 90]);
case '3d'
h = surf(x(1:xIntr:end), t(1:tIntr:end), PSI(1:tIntr:end, 1:xIntr:end), 'EdgeColor', 'none');
colorbar off;
view(-62,42)
shading interp
lightangle(-40,50);
h.FaceLighting = 'gouraud';
h.AmbientStrength = 0.3;
h.DiffuseStrength = 0.8;
h.SpecularStrength = 0.5;
h.SpecularExponent = 3;
h.BackFaceLighting = 'reverselit';
colormap(jet(256));
grid off;
otherwise
error('Unknown plotting mode');
end
hXLabel = xlabel('x');
hYLabel = ylabel('t');
hZLabel = zlabel('|\psi|^2');
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(x) max(x)] ,...
'YLim' , [floor(min(t)) ceil(max(t))]);
hx = xlabel('$t$','FontSize',11,'Interpreter','latex');
zlabel('$|\psi|^2$','FontSize',11,'Interpreter','latex');
hy = ylabel('$x$','FontSize',11,'Interpreter','latex');
end