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
LineSpecIterator.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 {
40  public:
41 
42  MarkerStyles = {"'s','d','o','*','p','x','+','^','v','<','>','.','h'"};
43 
44 
45  LineStyles = {"'-',':','-.','--'"};
46 
47 
48  Colors = "[ 0 0 1.0000,\
49  0 0.5000 0,\
50  1.0000 0 0,\
51  0 0.7500 0.7500,\
52  0.7500 0 0.7500,\
53  0.7500 0.7500 0,\
54  0.2500 0.2500 0.2500,\
55  0 1 0,\
56  .75 .75 .75,\
57  .9 .6 0,\
58  .2 1 .2,\
59  .5 .5 1]";
78  ShortColors = {"'r','g','b','c','m','y','k'"};
79 
80 
81  private:
82 
83  curl = 0;
84 
85  curm = 0;
86 
87  curc = 0;
88 
89  cursc = 0;
90 
91  excluded_cols = "[]";
92 
93 
94  public:
95 
96  LineSpecIterator(ncolors,seed) {
97  predef = [ 0 0 1.0000;
98  0 0.5000 0;
99  1.0000 0 0;
100  0 0.7500 0.7500;
101  0.7500 0 0.7500;
102  0.7500 0.7500 0;
103  0.2500 0.2500 0.2500];
104  if nargin < 2
105  seed = round(100*cputime);
106  if nargin < 1
107  ncolors = size(predef,1);
108  end
109  end
110  maxintensity = .7;
111  np = size(predef,1);
112  if ncolors > np
113  num = ncolors - np;
114  colors = zeros(ncolors,3);
115  colors(1:np,:) = predef;
116  r = RandStream(" mt19937ar "," Seed ",seed);
117  mindiff = .3;
118  for n=1:num
119  color = r.rand(1,3)*maxintensity;
120  cnt = 1;
121  while any(sum(abs(repmat(color,np+n-1,1)-colors(1:np+n-1,:)),2) < mindiff)
122  color = r.rand(1,3)*maxintensity;
123  cnt = cnt+1;
124  if cnt > 1000
125  mindiff = mindiff*.8;
126  fprintf(" LinSpecIterator: Couldn "" t find any new sufficiently distant color. Choosing new mindiff=%g\n ",mindiff);
127  cnt = 1;
128  end
129  end
130  colors(np+n,:) = color;
131  end
132  this.Colors= colors;
133  else
134  this.Colors= predef(1:ncolors,:);
135  end
136  }
137 
138 
139  function markerstyle = nextMarkerStyle() {
140  markerstyle = this.MarkerStyles[this.curm+1];
141  this.curm= mod(this.curm+1,length(this.MarkerStyles));
142  }
143 
144 
145  function linestyle = nextLineStyle() {
146  linestyle = this.LineStyles[this.curl+1];
147  this.curl= mod(this.curl+1,length(this.LineStyles));
148  }
149 
150 
151  function ls = nextColorLineStyle() {
152  ls = [this.ShortColors[this.cursc+1] this.nextLineStyle];
153  this.cursc= mod(this.cursc+1,length(this.ShortColors));
154  }
155 
156 
157  function c = nextShortColor(linestyle) {
158  if nargin < 2
159  linestyle = " - ";
160  end
161  c = [this.ShortColors[this.cursc+1] linestyle];
162  this.cursc= mod(this.cursc+1,length(this.ShortColors));
163  }
164 
165 
166  function color = nextColor() {
167  color = this.Colors(this.curc+1,:);
168  this.curc= mod(this.curc+1,size(this.Colors,1));
169  if ~isempty(this.excluded_cols)
170  cnt = 1;
171  while any(sum(abs(repmat(color,size(this.excluded_cols,1),1)-this.excluded_cols),2) < .3)
172  /* Pick next one */
173  color = this.Colors(this.curc+1,:);
174  this.curc= mod(this.curc+1,size(this.Colors,1));
175 
176  cnt = cnt+1;
177  if cnt == size(this.Colors,1)
178  warning(" KerMor:LineSpecInterator ",...
179  " Out of pre-defined colors (all excluded). Using random color. ");
180  color = rand(1,3);
181  this.Colors= [this.Colors; color];
182  break;
183  end
184  end
185  end
186  /* fprintf('New color: [%g %g %g]\n',color); */
187  }
188 
189 
190  function excludeColor(data) {
191  if size(data,2) == 3
192  color = data;
193  elseif ishandle(data)
194  color = [];
195  for i=1:length(data)
196  color = [color; get(data(i)," Color ")];/* #ok */
197 
198  end
199  end
200  this.excluded_cols= [this.excluded_cols; color];
201  }
202 
203 
204 
205 };
206 
Colors
start of custom colors
function excludeColor(data)
LineSpecIterator(ncolors, seed)
Matlab's base handle class (documentation generation substitute)
function color = nextColor()
function markerstyle = nextMarkerStyle()
function linestyle = nextLineStyle()
function ls = nextColorLineStyle()
function c = nextShortColor(linestyle)
LinSpecIterator: Small helper class to automatically iterate through different line styles/markers/co...