Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@helper/obj2tex.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % OBJ2TEX converts the input data to TeX code | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: OBJ2TEX converts the input data to TeX code | |
5 % | |
6 % utils.helper.obj2tex(obj) | |
7 % txt = utils.helper.obj2tex(obj) Returns the display text | |
8 % | |
9 % | |
10 % HISTORY: 3-09-2010 A. Grynagier | |
11 % Creation | |
12 % | |
13 % VERSION: $Id: obj2tex.m,v 1.2 2010/09/06 17:07:58 adrien Exp $ | |
14 % | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = obj2tex(varargin) | |
19 if nargin~=1 | |
20 error(['utils.helper.obj2tex only takes one input object at a time and nargin is ' num2str(nargin)]) | |
21 end | |
22 %#ok<*AGROW> | |
23 obj = varargin{1}; | |
24 % objClasses = {'param' 'tsdata' 'data2D' 'paramValue' 'smodel' 'unit' 'data3D' 'parfrac' 'specwin' ... | |
25 % 'filterbank' 'pest' 'xydata' 'fsdata' 'matrix' 'plist' 'ssm' 'xyzdata' 'mfir' ... | |
26 % 'ssmblock' 'ao' 'ltpda_data' 'miir' 'pz' 'ssmport' 'cdata' 'ltpda_filter' 'pzmodel' 'time'... | |
27 % 'collection' 'msym' 'rational' 'timespan'} | |
28 % otherClasses = {'double' 'sym' 'char'} | |
29 % if numel(obj)~=1 | |
30 % error('only takes a single object') | |
31 % txt = cell(size(objs)); | |
32 % for ii=1:numel(txt) | |
33 % txt{ii} = utils.helper.obj2tex(obj(ii)); | |
34 % end | |
35 % varargout = txt; | |
36 % if nargout == 0 | |
37 % display(txt) | |
38 % end | |
39 % return | |
40 % elseif numel(obj)==0 | |
41 %% special cases for empty objects | |
42 if numel(obj)==0 | |
43 switch lower(class(obj)) | |
44 case {'double' 'logical' 'cell' 'sym'} | |
45 otherwise | |
46 varargout = {''}; | |
47 return | |
48 end | |
49 end | |
50 | |
51 %% dealing with objects of size more than one | |
52 if numel(obj)>1 | |
53 switch lower(class(obj)) | |
54 case {'double' 'logical' 'ao' 'ssmblock' 'sym' 'cell' 'char'} | |
55 case {'plist' 'units' 'parfrac' 'pest' 'miir' 'rational' 'pzmodel'} | |
56 error('multiple objects of this class are not handled yet') | |
57 otherwise | |
58 varargout = {''}; | |
59 return | |
60 end | |
61 end | |
62 | |
63 %% dealing with objects | |
64 switch lower(class(obj)) | |
65 case 'ao' %% ao, does not plot content | |
66 txt = ' \begin{tabular}{cll} NAME & DESCRIPTION & DATA \\ \hline \\ '; | |
67 for ii=1:numel(obj) | |
68 if ii>1 | |
69 txt = [txt ' \\ ']; | |
70 end | |
71 txt = [ txt ' \texttt{' utils.helper.obj2tex(obj(ii).name) '} & ' utils.helper.obj2tex(obj(ii).description) ' & ' utils.helper.obj2tex(obj(ii).data) ]; | |
72 end | |
73 txt = [txt ' \end{tabular} ']; | |
74 | |
75 case 'plist' %% plist, does not plot all options so far. A tabular may be better... TBC... | |
76 txt = ' \begin{tabular}{cll} KEY & VALUE & DESCRIPTION \\ \hline \\ '; | |
77 for ii=1:obj.nparams | |
78 if ii>1 | |
79 txt = [txt ' \\ ']; | |
80 end | |
81 txt = [txt ' \texttt{' utils.helper.obj2tex(obj.params(ii).key) '} & $ ' utils.helper.obj2tex( obj.params(ii).getVal ) ' $ ']; | |
82 objmin = obj.params(ii).getProperty('min'); | |
83 objmax = obj.params(ii).getProperty('max'); | |
84 objunits = obj.params(ii).getProperty('units'); | |
85 if ~isempty(objmin) && ~isempty(objmax ) | |
86 txt = [ txt ' $ \in \left[ ' utils.helper.obj2tex( eval(objmin) ) ';' utils.helper.obj2tex( eval(objmax) ) ' \right] $ ' ]; | |
87 end | |
88 if ~isempty(objunits) | |
89 if ischar( objunits ) | |
90 objunits = strrep( objunits , '(' , ''); | |
91 objunits = strrep( objunits , ')' , ''); | |
92 objunits = strrep( objunits , ' ^' , '^'); | |
93 end | |
94 txt = [ txt ' $ \, ' utils.helper.obj2tex( unit(objunits) ) ' $ ' ]; | |
95 elseif ischar(objunits) | |
96 txt = [ txt ' $ \, ' utils.helper.obj2tex( unit ) ' $ ' ]; | |
97 end | |
98 txt = [txt ' & ' utils.helper.obj2tex( obj.params(ii).desc ) ]; | |
99 end | |
100 txt = [txt ' \end{tabular} ']; | |
101 | |
102 case 'param' %% called by the plist function | |
103 error('param should always be provided inside a plist object') | |
104 | |
105 case lower('paramValue') | |
106 error('paramValue should always be provided inside a param object') | |
107 | |
108 case 'smodel' | |
109 % { 'expr' 'params' 'values' 'trans' 'xvar' 'xvals' 'xunits' 'yunits' 'name'} | |
110 error('smodel is not supported yet') | |
111 | |
112 case 'unit' | |
113 txt = ' \left['; | |
114 if numel(obj.strs)==0 | |
115 txt = [txt ' - ']; | |
116 else | |
117 for ii=1:numel(obj.strs) | |
118 if ii>1 | |
119 txt = [txt ' \,' ]; | |
120 end | |
121 p = val2prefix(obj.vals(ii)); | |
122 if obj.exps(ii) == 0 | |
123 elseif obj.exps(ii) == 1 | |
124 txt = [txt ' \mathrm{' p ' ' obj.strs{ii} '} ' ]; | |
125 else | |
126 txt = [txt ' \mathrm{' p ' ' obj.strs{ii} '}^{' num2str(obj.exps(ii)) '}' ]; | |
127 end | |
128 end | |
129 end | |
130 txt = [txt ' \right] ']; | |
131 | |
132 case 'parfrac' | |
133 %{ 'res' 'poles' 'pmul' 'dir' 'iunits' 'ounits' 'name' } | |
134 display('warning, the parfrac was not tested so far') | |
135 txt = [' G_{\texttt{' utils.helper.obj2tex(obj.name) '}} (s) = ']; | |
136 for ii=1:numel(obj.res) | |
137 if ii>1 | |
138 txt = [txt ' + ']; | |
139 end | |
140 if obj.pmul(ii)>1 | |
141 txt = [txt '\frac{ ' utils.helper.obj2tex(obj.res(ii)) ' }{ \left( s-' utils.helper.obj2tex(obj.poles(ii)) ' \right)^{' utils.helper.obj2tex(obj.pmul(ii)) '} }' ]; | |
142 elseif obj.pmul(ii)==1 | |
143 txt = [txt '\frac{ ' utils.helper.obj2tex(obj.res(ii)) ' }{ s-(' utils.helper.obj2tex(obj.poles(ii)) ') }' ]; | |
144 end | |
145 end | |
146 txt = [txt ' + ' utils.helper.obj2tex(obj.dir) ]; | |
147 txt = [txt ' \, ' utils.helper.obj2tex( simplify(obj.ounits/obj.iunits) ) ]; | |
148 | |
149 case 'filterbank' | |
150 %{'filters' 'type' 'name' } | |
151 error('filterbank is not supported yet') | |
152 | |
153 case 'pest' | |
154 %{ 'dy' 'y' 'names' 'yunits' 'pdf' 'cov' 'corr' 'chi2' 'dof' 'chain' 'name' } | |
155 % plotting names | |
156 txt = ' \left[ \begin{array}{c} '; | |
157 for ii=1:numel(obj.y) | |
158 if ii>1 | |
159 txt = [txt ' \\ ' ]; | |
160 end | |
161 txt = [txt '\mathrm{' utils.helper.obj2tex(obj.names{ii}) '}' ]; | |
162 end | |
163 txt = [ txt ' \end{array} \right] = ']; | |
164 % plotting values | |
165 txt = [ txt ' \left[ \begin{array}{rl} ' ]; | |
166 for ii=1:numel(obj.y) | |
167 if ii>1 | |
168 txt = [txt ' \\ ' ]; | |
169 end | |
170 if ~isempty(obj.dy) | |
171 txt = [txt utils.helper.obj2tex(num2str(obj.y(ii))) ' \, \pm \, ' utils.helper.obj2tex(num2str(obj.dy(ii))) ' & ' utils.helper.obj2tex(obj.yunits(ii)) ]; | |
172 else | |
173 txt = [txt utils.helper.obj2tex(num2str(obj.y(ii))) ' & ' utils.helper.obj2tex(obj.yunits(ii)) ]; | |
174 end | |
175 end | |
176 txt = ' \end{array} \right] '; | |
177 if ~isempty(obj.corr) | |
178 txt = [txt ' \\ \mathrm{CORR}= \left[ ' utils.helper.obj2tex(obj.corr) ' \right] ']; | |
179 end | |
180 if ~isempty(obj.cov) | |
181 txt = [txt ' \\ \mathrm{COV}= \left[ ' utils.helper.obj2tex(obj.cov) ' \right] ']; | |
182 end | |
183 if ~isempty(obj.cov) | |
184 txt = [txt ' \\ \chi_2 = ' utils.helper.obj2tex(obj.chi2) ]; | |
185 end | |
186 | |
187 case 'matrix' | |
188 %{ 'objs' 'name' } | |
189 error('matrix is not supported yet') | |
190 | |
191 case 'ssm' | |
192 %{ 'amats' 'bmats' 'cmats' 'dmats' 'timestep' 'inputs' 'states' 'outputs' 'numparams' 'params' ... | |
193 % 'Ninputs' 'inputsizes' 'Noutputs' 'outputsizes' 'Nstates' 'statesizes' 'Nnumparams' 'Nparams' 'isnumerical' 'name' } | |
194 txt = '\begin{longtable}{|rl|} \hline \textbf{FIELD} & \textbf{PROPERTY} \\ \hline \hline '; | |
195 txt = [txt ' \textbf{NAME:} & \texttt{' utils.helper.obj2tex(obj.name) '} ']; | |
196 txt = [ txt ' \\ \hline & \\[3pt] \textbf{DESCRIPTION:} & ' utils.helper.obj2tex(obj.description) ' ' ]; | |
197 txt = [ txt ' \\ \hline & \\[3pt] \textbf{REALIZATION:} & $ \begin{array}{c|c} A & B \\ \hline C & D \end{array} ' ]; | |
198 txt = [ txt ' \sim \begin{array}{c|c} ' utils.helper.obj2tex(obj.amats) ' & ' utils.helper.obj2tex(obj.bmats) ' \\ \hline ' ]; | |
199 txt = [ txt utils.helper.obj2tex(obj.cmats) ' & ' utils.helper.obj2tex(obj.dmats) ' \end{array} $']; | |
200 txt = [ txt ' \\ \hline \textbf{TIMESTEP:} & ' utils.helper.obj2tex(obj.timestep) ' $' utils.helper.obj2tex( unit('s') ) '$' ]; | |
201 txt = [ txt ' \\ \hline & \\[3pt] \textbf{INPUTS:} & ' utils.helper.obj2tex(obj.inputs) ]; | |
202 txt = [ txt ' \\ \hline & \\[3pt] \textbf{STATES:} & ' utils.helper.obj2tex(obj.states) ]; | |
203 txt = [ txt ' \\ \hline & \\[3pt] \textbf{OUTPUTS:} & ' utils.helper.obj2tex(obj.outputs) ]; | |
204 txt = [ txt ' \\ \hline & \\[3pt] \textbf{PARAMS:} & ' utils.helper.obj2tex(obj.params) ]; | |
205 txt = [ txt ' \\ \hline & \\[3pt] \textbf{NUMPARAMS:} & ' utils.helper.obj2tex(obj.numparams) ]; | |
206 txt = [ txt ' \\ \hline \end{longtable} ' ]; | |
207 | |
208 case 'mfir' | |
209 %{ 'gd' 'ntaps' 'fs' 'a' 'iunits' 'ounits' 'name' } | |
210 error('mfir is not supported yet') | |
211 | |
212 case 'ssmblock' | |
213 %{ 'name' 'ports' } | |
214 txt = ' \begin{tabular}{r|lcl} BLOCK & PORT & UNITS & DESCRIPTION '; | |
215 | |
216 for kk = 1:numel(obj) | |
217 txt = [txt ' \\ \hline ']; | |
218 for ii=1:numel(obj(kk).ports) | |
219 [blockName, portName] = ssmblock.splitName(obj(kk).ports(ii).name); | |
220 if ~strcmp(blockName, obj(kk).name) | |
221 portName = obj(kk).ports(ii).name; | |
222 end | |
223 if ii>1 | |
224 txt = [txt ' \\ ']; | |
225 end | |
226 if ii==1 | |
227 txt = [txt ' \texttt{' utils.helper.obj2tex(obj(kk).name) '} & & & ' utils.helper.obj2tex(obj(kk).description) ' \\ ']; | |
228 end | |
229 txt = [txt ' & \texttt{' utils.helper.obj2tex(portName) '} & $ ' utils.helper.obj2tex(obj(kk).ports(ii).units) ' $ & ' utils.helper.obj2tex(obj(kk).ports(ii).description) ' ']; | |
230 end | |
231 end | |
232 txt = [ txt ' \end{tabular} ']; | |
233 | |
234 case 'pz' | |
235 %{ 'f' 'q' 'ri'} | |
236 if isnan(obj.q) | |
237 txt = [' \left( s - 2 \pi \left( ' num2str(obj.f) '\right) \right) ' ]; | |
238 else | |
239 txt = [' \left( s^2 + 2 \pi \left( \frac{' utils.helper.obj2tex(obj.f) '}{' utils.helper.obj2tex(obj.q) '} \right) s + 4 \pi^2 \left(' utils.helper.obj2tex(abs(obj.f)) '\right)^2 s^2 \right) ' ]; | |
240 end | |
241 | |
242 case 'ssmport' | |
243 %{'name' 'units' } | |
244 error('ssmports should always be provided inside a ssmblock object') | |
245 | |
246 case 'pzmodel' | |
247 %{ 'poles' 'zeros' 'gain' 'delay' 'iunits' 'ounits' 'name' } | |
248 txt = [' G_{\texttt{' utils.helper.obj2tex(obj.name) '}} (s) = ' utils.helper.obj2tex(obj.gain) ' \times \frac{']; | |
249 if numel(obj.zeros)>0 | |
250 for ii=1:numel(obj.zeros) | |
251 txt = [txt utils.helper.obj2tex(obj.zeros(ii)) ]; | |
252 end | |
253 else | |
254 txt = [txt ' 1 ' ]; | |
255 end | |
256 txt = [ txt ' }{ ']; | |
257 if numel(obj.poles)>0 | |
258 for ii=1:numel(obj.poles) | |
259 txt = [txt utils.helper.obj2tex(obj.poles(ii)) ]; | |
260 end | |
261 else | |
262 txt = [txt ' 1 ' ]; | |
263 end | |
264 txt = [txt ' } ' utils.helper.obj2tex( simplify(obj.ounits/obj.iunits) ) ]; | |
265 | |
266 case 'collection' | |
267 %{ 'objs' 'name' } | |
268 error('collection is not supported yet') | |
269 | |
270 case 'msym' | |
271 %{'use fieldnames'} | |
272 txt = obj.s; | |
273 txt = strrep(txt, '*', '\times'); | |
274 txt = strrep(txt, '(', '{ \left('); | |
275 txt = strrep(txt, ')', '\right) }'); | |
276 | |
277 case 'specwin' | |
278 %{ 'type' 'alpha' 'psll' 'rov' 'nenbw' 'w3db' 'flatness' 'ws' 'ws2' 'win'} | |
279 error('specwin is not supported yet') | |
280 | |
281 case 'miir' | |
282 %{ 'b' 'ntaps' 'fs' 'a' 'iunits' 'ounits' 'name' } | |
283 %{ 'poles' 'zeros' 'gain' 'delay' 'iunits' 'ounits' 'name' } | |
284 txt = [' G_{\texttt{' utils.helper.obj2tex(obj.name) '}} (z) = \frac{']; | |
285 for ii=1:numel(obj.a) | |
286 if ii>1 && obj.a(ii)>=0 | |
287 txt = [txt ' + ']; | |
288 end | |
289 txt = [txt utils.helper.obj2tex(obj.a(ii)) 'z^{-' num2str(ii) '}' ]; | |
290 end | |
291 txt = [ txt ' }{ ']; | |
292 for ii=1:numel(obj.b) | |
293 if ii>1 && obj.b(ii)>=0 | |
294 txt = [txt ' + ']; | |
295 end | |
296 txt = [txt utils.helper.obj2tex(obj.b(ii)) 'z^{-' num2str(ii) '}' ]; | |
297 end | |
298 txt = [txt ' } ' utils.helper.obj2tex( simplify(obj.ounits/obj.iunits) ) ]; | |
299 | |
300 case 'rational' | |
301 %{ 'num' 'den' 'iunits' 'ounits' 'name' } | |
302 %{ 'poles' 'zeros' 'gain' 'delay' 'iunits' 'ounits' 'name' } | |
303 txt = [' G_{\texttt{' utils.helper.obj2tex(obj.name) '}} (s) = \frac{']; | |
304 for ii=1:numel(obj.num) | |
305 if ii>1 && obj.num(ii) >=0 | |
306 txt = [txt ' + ']; | |
307 end | |
308 txt = [txt utils.helper.obj2tex(obj.num(ii)) 's^{' num2str(ii) '}' ]; | |
309 end | |
310 txt = [ txt ' }{ ']; | |
311 for ii=1:numel(obj.den) | |
312 if ii>1 && obj.den(ii)>=0 | |
313 txt = [txt ' + ']; | |
314 end | |
315 txt = [txt utils.helper.obj2tex(obj.den(ii)) 's^{' num2str(ii) '}' ]; | |
316 end | |
317 txt = [txt ' } ' utils.helper.obj2tex( simplify(obj.ounits/obj.iunits) ) ]; | |
318 | |
319 case 'timespan' | |
320 %{ 'startT' 'endT' 'interval' 'timeformat' 'timezone' 'name' } | |
321 error('timespan is not supported yet') | |
322 | |
323 case 'tsdata' | |
324 %{ 't0' 'fs' 'nsecs' 'xunits' 'yunits' 'x' 'y' 'dx' 'dy'} | |
325 txt = [ ' $(1 \times ' utils.helper.obj2tex(numel(obj.y)) ')$ times series, units: $' utils.helper.obj2tex(obj.yunits) '$vs$' utils.helper.obj2tex(obj.xunits) ' $ at $' num2str(obj.fs) '$Hz ']; | |
326 | |
327 case 'xydata' | |
328 txt = [ ' $(1 \times ' utils.helper.obj2tex(numel(obj.y)) ')$ x-y data, units: $' utils.helper.obj2tex(obj.yunits) '$vs$' utils.helper.obj2tex(obj.xunits) '$ ']; | |
329 %{ 'xunits' 'yunits' 'x' 'y' 'dx' 'dy'} | |
330 | |
331 case 'fsdata' | |
332 %{ 't0' 'navs' 'fs' 'enbw' 'xunits' 'yunits' 'x' 'y' 'dx' 'dy'} | |
333 txt = [ ' $(1 \times ' utils.helper.obj2tex(numel(obj.y)) ')$ frequency series, units: $' utils.helper.obj2tex(obj.yunits) '$vs$' utils.helper.obj2tex(obj.xunits) ' $ up to $' num2str(obj.fs) '$Hz ']; | |
334 | |
335 case 'xyzdata' | |
336 %{ 'zunits' 'z' 'xunits' 'yunits' 'x' 'y' 'dx' 'dy'} | |
337 display('warning, xyz data was not tested yet') | |
338 txt = [ ' $(' utils.helper.obj2tex(numel(obj.x)) ' \times ' utils.helper.obj2tex(numel(obj.y)) ')$ table, units: $' utils.helper.obj2tex(obj.yunits) '$vs$ \left(' utils.helper.obj2tex(obj.xunits) ' \times ' utils.helper.obj2tex(obj.yunits) '\right)$ ']; | |
339 | |
340 case 'cdata' | |
341 %{ 'yunits' 'y' 'dy'} | |
342 error('cdata is not supported yet') | |
343 | |
344 case 'double' | |
345 [n1, n2] = size(obj); | |
346 if n1==0 || n2==0 | |
347 % array of size 0 | |
348 txt = [' 0_{ \left[ ' num2str(n1) ' \times ' num2str(n2) ' \right] } ']; | |
349 elseif n1==1 && n2==1 | |
350 % array of size 1 | |
351 if isnan(obj) | |
352 txt = '\mathrm{NaN}'; | |
353 elseif isinf(obj) | |
354 txt = ' \pm \infty '; | |
355 else | |
356 if isreal(obj) | |
357 txt1 = num2str(obj, '%10.5e'); | |
358 [txt2, txt1] = strtok(txt1, 'e'); | |
359 expo = eval(txt1(2:end)); | |
360 if expo==0 | |
361 txt = [ ' ' txt2 ' ' ]; | |
362 else | |
363 txt = [ ' ' txt2 '.10^{' num2str(expo) '} ' ]; | |
364 end | |
365 else | |
366 if imag(obj)>= 0 | |
367 txt = [ ' ' utils.helper.obj2tex( real(obj) ) '+' utils.helper.obj2tex( imag(obj) ) ' i ' ]; | |
368 else | |
369 txt = [ ' ' utils.helper.obj2tex( real(obj) ) '' utils.helper.obj2tex( imag(obj) ) ' i ' ]; | |
370 end | |
371 end | |
372 end | |
373 else | |
374 % array of size nxm | |
375 txt = ' \left[ \begin{array}{'; | |
376 for ii=1:size(obj,2) | |
377 txt = [txt 'c' ]; | |
378 end | |
379 txt = [txt '} ']; | |
380 for ii=1:size(obj,1) | |
381 for jj=1:size(obj,2) | |
382 if jj>1 | |
383 txt = [ txt ' & ']; | |
384 end | |
385 val = obj(ii,jj); | |
386 txt = [ txt ' ' utils.helper.obj2tex(val) ]; % reccursive call with a singleton | |
387 end | |
388 if ii<size(obj,1) | |
389 txt = [ txt ' \\ ' ]; | |
390 end | |
391 end | |
392 txt = [ txt ' \end{array} \right] ' ]; | |
393 end | |
394 | |
395 case 'logical' | |
396 txt = utils.helper.obj2tex( double(obj) ); | |
397 | |
398 case 'sym' | |
399 error('sym is not supported yet') | |
400 | |
401 case 'cell' | |
402 [n1, n2] = size(obj); | |
403 if n1==0 || n2==0 | |
404 % array of size 0 | |
405 txt = [' \texttt{cell}_{ \left[ ' num2str(n1) ' \times ' num2str(n2) ' \right] } ']; | |
406 elseif n1==1 && n2==1 | |
407 % array of size 1 | |
408 txt = ['{' num2str(size(obj{1},1)) ' \times ' num2str(size(obj{1},2)) ' \texttt{ ' class(obj{1}) '} } ' ]; | |
409 else | |
410 % array of size mxn | |
411 txt = ' \left[ \begin{array}{'; | |
412 for ii=1:size(obj,2) | |
413 txt = [txt 'c' ]; | |
414 end | |
415 txt = [txt '} ']; | |
416 for ii=1:size(obj,1) | |
417 for jj=1:size(obj,2) | |
418 if jj>1 | |
419 txt = [ txt ' & ']; | |
420 end | |
421 val = obj{ii,jj}; | |
422 txt = [ txt ' {' num2str(size(val,1)) ' \times ' num2str(size(val,2)) ' \texttt{ ' class(val) '} } ' ]; | |
423 end | |
424 if ii<size(obj,1) | |
425 txt = [ txt ' \\ ' ]; | |
426 end | |
427 end | |
428 txt = [ txt ' \end{array} \right] ' ]; | |
429 end | |
430 | |
431 case 'char' | |
432 txt = obj; | |
433 txt = strrep( txt, '_', '\_'); | |
434 txt = strrep( txt, '^', '\^'); | |
435 txt = strrep( txt, '->', '$\rightarrow$'); | |
436 | |
437 otherwise | |
438 error(['conversion to TeX is not yet implemented for class ' class(obj) '!']) | |
439 end | |
440 | |
441 if nargout == 0 | |
442 display(txt); | |
443 elseif nargout == 1 | |
444 varargout{1} = txt; | |
445 end | |
446 end | |
447 | |
448 | |
449 | |
450 | |
451 | |
452 | |
453 | |
454 | |
455 | |
456 | |
457 | |
458 | |
459 | |
460 | |
461 | |
462 % private function of unit class | |
463 | |
464 function p = val2prefix(val) | |
465 [pfxs, pfxvals] = unit.supportedPrefixes; | |
466 res = val==pfxvals; | |
467 if any(res) | |
468 p = pfxs{val==pfxvals}; | |
469 else | |
470 p = ''; | |
471 end | |
472 end |