File: integ.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 (37 lines) | stat: -rw-r--r-- 864 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
function som = integ(y,x,orient) 
rhs=argn(2)
if size(y,1) == 1 then y = y(:);end
if rhs == 1 then 
  x = 1:size(y,1);
  orient='*'
elseif rhs==2 then
  if size(y,1)>1 &size(x,'*')==1 then
    orient=x
    x = 1:size(y,orient);
  else
    orient='*'
  end
end
if orient=='*' then
  y=y(:)
  if size(x,'*') ~= size(y,1)
    error('X and Y have incomptaible size')
  end
  dy = y(1:$-1) + y(2:$) ;
  dx = (x(2:$)-x(1:$-1))/2 ;
  som = matrix(dx,1,-1)*dy ;
elseif orient==1|orient=='r' then
  if size(x,'*') ~= size(y,1)
    error('X and Y have incomptaible size')
  end
  dy = y(1:$-1,:) + y(2:$,:) ;
  dx = (x(2:$)-x(1:$-1))/2 ;
  som = matrix(dx,1,-1)*dy ;
elseif orient==2|orient=='c' then
  if size(x,'*') ~= size(y,2)
    error('X and Y have incomptaible size')
  end
  dy = y(:,1:$-1) + y(:,2:$) ;
  dx = (x(2:$)-x(1:$-1))/2 ;
  som = dy*matrix(dx,-1,1) ;
end