File: sci_meshgrid.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (54 lines) | stat: -rw-r--r-- 1,145 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
function [stk,txt,top]=sci_meshgrid()
// Copyright INRIA
txt=[]
if rhs<=2 then
  if rhs==1 then
    X=stk(top)(1);[mx,nx]=checkdims(stk(top));
    Y=X;my=mx;ny=nx;
  else
    X=stk(top-1)(1);[mx,nx]=checkdims(stk(top-1));
    Y=stk(top)(1);[my,ny]=checkdims(stk(top));
  end
  txt='// inline translation of meshgrid('+makeargs([X,Y])+')'
  if lhs==2 then
    [U,V]=lhsvarsnames()
    if mx==1 then
      txt=[txt;U+'='+X]
    else
      txt=[txt;
	  U+'=matrix('+X+',1,-1)']
    end
    if ny==1 then
      txt=[txt;V+'='+Y]
    else
      txt=[txt;
	  V+'=matrix('+Y+',-1,1)']
    end
    
    txt=[txt;
	U+'='+U+'(ones('+U+'),:)'
	V+'='+V+'(:,ones('+V+')'')']
    stk=list(list(U,'0','?','?','1'),list(V,'0','?','?','1'))
  else
    U=lhsvarsnames()
    if U==[] then U=gettempvar(),end
    if mx==1 then
      txt=[txt;U+'='+X]
    else
      txt=[txt;
	  U+'=matrix('+X+',1,-1)']
    end
    
    txt=[txt;
	U+'='+U+'(ones('+U+'),:)']
    stk=list(U,'0','?','?','1')
  end
else
  X=stk(top-2)(1)
  Y=stk(top-1)(1)
  Z=stk(top)(1)
  X='mtlb_meshgrid('+makeargs([X,Y,Z])+')'
  stk=list(list(X,'-1','?','?','1'),list(X,'-1','?','?','1'))
end