File: sci_stem.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (59 lines) | stat: -rw-r--r-- 1,479 bytes parent folder | download
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
function [stk,txt,top]=sci_stem()
// Copyright INRIA
txt=[]
if rhs==3|stk(top)(5)=='10' then
  style=linetype(stk(top)(1))
  top=top-1
  rhs=rhs-1
else
  style=-1
end

style=sci2exp(style)
if rhs==1 then
  x=tempvar(1)
  if isname(stk(top)(1)) then
    y=stk(top)(1)
  else
    y=tempvar(2)
    txt=y+' = '+stk(top)(1);
  end
  txt=[txt;
      x+' = 1:size('+y+',''*''))'
      'plot2d'+rhsargs([x,y,'-9'])]
  if stk(top)(3)=='1' then // row vector
    txt=[txt;'xsegs'+rhsargs(['[1;1]*'+x,'[1;1]*'+y,style])]
  elseif stk(top)(4)=='1' then // column vector    
    txt=[txt;'xsegs'+rhsargs(['[1;1]*'+x,'[1;1]*'+y+'''',style])]
  else   // unknown shape
    txt=[txt;'xsegs'+rhsargs(['[1;1]*'+x,'[1;1]*'+y+'(:)''',style])]
  end
elseif rhs==2 then     
  if isname(stk(top)(1)) then
    y=stk(top)(1)
  else
    y=tempvar(2)
    txt=[txt;y+' = '+stk(top)(1)];
  end
  if isname(stk(top-1)(1)) then
    x=stk(top-1)(1)
  else
    y=tempvar(2)
    txt=[txt;y+' = '+stk(top-1)(1)];
  end
  if stk(top)(4)=='1' then //y is a column vector 
    txt=[txt;y+' = '+y+'''']
  elseif stk(top)(3)<>'1' then //y has unknown shape
    txt=[txt;y+' = '+y(:)+'''']
  end
  if stk(top-1)(4)=='1' then //x is a column vector 
    txt=[txt;x+' = '+x+'''']
  elseif stk(top-1)(3)<>'1' then //x has unknown shape
    txt=[txt;x+' = '+x(:)+'''']
  end
  txt=[txt;
      'plot2d'+rhsargs([x,y,'-9'])
      'xsegs'+rhsargs(['[1;1]*'+x,'[1;1]*'+y,style])]
  top=top-1
end
stk=list(' ','-2','0','0','0')