rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
animate_basisgen_error.m
1 function animate_basisgen_error(detailed_data, params)
2 
3 save_avi = 1;
4 
5 params.animation_pause = 0.10;
6 
7 plot_params.plot_mode = '3d';
8 plot_params.view = [-24,22];
9 
10 switch params.RB_generation_mode
11  case 'greedy_uniform_fixed'
12  par.numintervals = params.RB_numintervals;
13  par.range = params.mu_ranges;
14  MMesh = cubegrid(par);
15  otherwise
16  error('RB_generation_mode not supported for animation');
17 end
18 
19 figure;
20 set(gcf, 'Position', [50 50 800 700]);
21 
22 if save_avi == 1
23  disp('generating basisgen.avi');
24  mov = avifile(fullfile(rbmatlabresult,'basisgen_animat.avi'));
25  mov.Quality = 100;
26  mov = set(mov,'Compression','None');
27  frame_rep = ceil(15*params.animation_pause);
28 end;
29 
30 errs_sequence = detailed_data.RB_info.post_errs_sequence;
31 est_sequence = detailed_data.RB_info.post_est_sequence;
32 
33 %mu_values = detailed_data.RB_info.mu_sequence;
34 
35 vertices = get(MMesh,'vertex');
36 
37 for i = 1:size(detailed_data.RB_info.post_errs_sequence,2);
38 
39  lambda = 1;%max(1, 10^(floor(log10(...
40  % min(est_sequence(:,i))/(2*max(errs_sequence(:,i))) ...
41  % ))));
42 % epsilon = 1e-20;
43  [err,j] = max(est_sequence(:,i));
44  [err,k] = max(errs_sequence(:,i));
45 % j = find_vector(mu_values(:,i+1), vertices',epsilon);
46  if (isempty(j) || length(j)>1)
47  error('vector not or multiply found in vertex list!!');
48  end;
49  cla;
50  plot_leafvertex_data(est_sequence(:,i),MMesh,plot_params); hold on;
51  plot_leafvertex_data(errs_sequence(:,i)*lambda,MMesh,plot_params); hold on;
52  xlabel('mu_1');
53  ylabel('mu_2');
54  zlabel(['estimator above error (x', num2str(lambda), ')']);
55  zlim([10e-6,10e-1]);
56  set(gca,'ZTick',10.^(-5:0));
57 
58  pause(params.animation_pause);
59  if save_avi
60  F = getframe(gcf);
61  for fr = 1:frame_rep
62  mov = addframe(mov,F);
63  end;
64  end;
65  plot3(vertices(j,1),vertices(j,2),est_sequence(j,i),...
66  '.','MarkerSize',30); hold on;
67  plot3(vertices(k,1),vertices(k,2),errs_sequence(k,i)*lambda,...
68  '.','MarkerSize',30);
69  set(gca,'Zscale','log');
70 
71  title(['Estimator vs. error plot over M_{train} after RB size N=', ...
72  num2str(i), ', at t=T_{end}, with M=', num2str(params.M), ...
73  ' and Mstrich=', num2str(params.Mstrich)]);
74 
75  if save_avi
76  F = getframe(gcf);
77  for fr = 1:frame_rep
78  mov = addframe(mov,F);
79  end;
80  end;
81  pause(params.animation_pause);
82 end
83 
84 if save_avi
85  mov=close(mov);
86 end;
87 
A hierarchical cubegrid of arbitrary dimension.
Definition: cubegrid.m:17