-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotindices.m
38 lines (36 loc) · 1.1 KB
/
plotindices.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
function plotindices(z)
% PLOTINDICES Visualize the index sets of a 2d dim.-adaptive grid
% PLOTINDICES(Z) Z must be the sparse grid data as returned by
% SPVALS. SPVALS must be called with the option DimensionAdaptive
% 'on' (set options using SPSET).
%
% See also SPVALS, SPSET.
d = size(z.indices.forwardNeighbors, 2);
switch d
case 2
indices = spseq2full(z.indices);
plot(indices(:,1)+1,indices(:,2)+1,'kx','LineWidth',1);
hold on;
activeIndices = find(z.indices.active);
plot(indices(activeIndices,1)+1, ...
indices(activeIndices,2)+1,'bs','LineWidth',1);
if z.indices.active(z.activeIndices(1))
plot(indices(z.activeIndices(1),1)+1, ...
indices(z.activeIndices(1),2)+1,'rs', ...
'LineWidth',2);
end
title(['k = ' num2str(size(indices,1))]);
hold off;
grid on;
axis equal;
axis tight;
xlim = get(gca,'XLim');
ylim = get(gca,'YLim');
set(gca,'XLim', [0,xlim(2)+1]);
set(gca,'YLim', [0,ylim(2)+1]);
set(gca,'XTick', 1:xlim(2));
set(gca,'YTick', 1:ylim(2));
set(gca,'YDir','normal');
otherwise
error(['Visualization of index sets not available for d = ' num2str(d)]);
end