KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorMapCreator.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
18  :public handle {
38  public: /* ( Constant ) */
39 
40  static const Resolution = 1000;
41 
42 
43  public:
44 
45  LogPlot = false;
46 
47 
48  private:
49 
50  vals = "[]";
51 
52  cols = {""};
53 
54 
55  public:
56 
57 
58  function useJet(vals) {
59  this.addColor(vals(1),[0 0 1]);
60  this.addColor(vals(2),[0 1 1]);
61  this.addColor(vals(3),[1 1 0]);
62  this.addColor(vals(4),[1 0 0]);
63  }
64 
65 
66  function addColor(value,color,colorbefore) {
67  if nargin < 4
68  colorbefore = color;
69  end
70  this.vals(end+1) = value;
71  this.cols[end+1] = color;
72  if ~isequal(color, colorbefore)
73  this.vals(end+1) = value-1/this.Resolution;
74  this.cols[end+1] = colorbefore;
75  end
76  }
77 
78 
79  function cmap = create(Zdata) {
80  dvals = this.vals;
81  dcols = this.cols;
82 
83  if this.LogPlot
84  dvals = log10(dvals);
85  end
86 
87  if nargin > 1
88  if this.LogPlot
89  Zdata = log10(Zdata);
90  end
91  minZ = min(Zdata(:));
92  dvals(end+1) = minZ;
93  dcols[end+1] = [0 0 .5]; /* zeros(3,1) */
94 
95 
96  maxZ = max(Zdata(:));
97  dvals(end+1) = maxZ;
98  dcols[end+1] = [.5 0 0]; /* zeros(3,1); */
99 
100 
101  rem = dvals < minZ;
102  dvals(rem) = [];
103  dcols(rem) = [];
104  rem = dvals > maxZ;
105  dvals(rem) = [];
106  dcols(rem) = [];
107  end
108 
109  /* Colormap */
110  cmap = [];
111  if length(dvals) > 1
112  [val, idx] = sort(dvals," ascend ");
113  valrange = linspace(val(1),val(end),this.Resolution);
114  ncol = length(valrange);
115  r = zeros(ncol,1);
116  g = zeros(ncol,1);
117  b = zeros(ncol,1);
118 
119  curpos = 1;
120  curcol = dcols[idx(1)];
121  for k = 2:length(val)
122  nextcol = dcols[idx(k)];
123  [~,nextpos] = min(abs(valrange-val(k)));
124 
125  pos = curpos:nextpos;
126  r(pos) = linspace(curcol(1),nextcol(1),length(pos));
127  g(pos) = linspace(curcol(2),nextcol(2),length(pos));
128  b(pos) = linspace(curcol(3),nextcol(3),length(pos));
129 
130  curpos = nextpos;
131  curcol = nextcol;
132  end
133  cmap = [r g b];
134  end
135  }
136 
137 
138 
139 };
140 
function addColor(value, color, colorbefore)
LogPlot: Class with static functions for logarithmic plotting.
Definition: LogPlot.m:17
sort
ort the handle objects in any array in ascending or descending order.
ColorMapCreator:
Matlab's base handle class (documentation generation substitute)
function cmap = create(Zdata)
static const Resolution
function useJet(vals)