Differences From Artifact [b5ee4e9a89]:

To Artifact [ea33ca5e52]:


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
39
40
41

42
43
44
45
46
47
48
49
50
51
52
53
function tex = pol2tex(pol)
  ## pol2tex: converts polynomial into LaTeX form.
  ## tex = pol2tex(pol)
  




  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$



  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################









  n = length(pol);
  
  if pol(1) == 1
    if n>1
      tex = '';
    else
      tex = '1';
    endif
  else

    tex = sprintf(" %1.2f", pol(1));
  endif
  
  if n>2
    tex = sprintf("%ss^%1.f", tex, n-1);
  elseif n==2
    tex = sprintf("%ss", tex);
  else
    tex = sprintf("%s", tex);
  endif

  for i=2:n
    if pol(i)<0
      plusminus = '-';
    else
      plusminus = '+';
    endif

    tex = sprintf("%s %s %1.2f", tex, plusminus, abs(pol(i)));
    if i<n-1
      tex = sprintf("%ss^%1.0f", tex, n-i);
    elseif i==n-1
      tex = sprintf("%ss", tex); 
    else
      tex = sprintf("%s", tex);
    endif
  endfor
endfunction


|

|

>
>
>






>
>
>





>
>
>
>
>
>
>
>









>
|



|

|










>
|

|

|







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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function tex = pol2tex(pol,name,f)
  ## pol2tex: converts polynomial into LaTeX form.
  ## tex = pol2tex(pol,[name,f])
  
  ## pol  polynomial (row vector)
  ## name name of the variable (eg s or z)
  ## f    format of the coefficients (eg %2.4f)

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2001/05/10 11:44:40  gawthrop
  ## Useful conversion functions
  ##
  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################

  if nargin<2
    name = "s"
  endif
  
  if nargin<3
    f = "%2.2f";
  endif
  
  n = length(pol);
  
  if pol(1) == 1
    if n>1
      tex = '';
    else
      tex = '1';
    endif
  else
    ff = sprintf(" %s",f);
    tex = sprintf(ff, pol(1));
  endif
  
  if n>2
    tex = sprintf("%s{%s}^%i", tex, name, n-1);
  elseif n==2
    tex = sprintf("%s{%s}", tex, name);
  else
    tex = sprintf("%s", tex);
  endif

  for i=2:n
    if pol(i)<0
      plusminus = '-';
    else
      plusminus = '+';
    endif
    ff = sprintf("%%s %%s %s",f);
    tex = sprintf(ff, tex, plusminus, abs(pol(i)));
    if i<n-1
      tex = sprintf("%s{%s}^%i", tex, name, n-i);
    elseif i==n-1
      tex = sprintf("%s{%s}", tex, name); 
    else
      tex = sprintf("%s", tex);
    endif
  endfor
endfunction



MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]