File: freson.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (30 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (2)
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
function fr=freson(h)
// Copyright INRIA
[lhs,rhs]=argn(0)
[n,d]=h(['num','den']);
if type(n)==1 then n=poly(n,varn(d),'c'),end
d0=coeff(d,0)
if d0==0 then
   error('infinite gain at zero frequency'),
end;
ar0=abs(coeff(n,0)/d0)^2
//look for  omega such that derivative of magn. is zero
niw=horner(n,%i*poly(0,'w'));
diw=horner(d,%i*poly(0,'w'))
niw=real(niw*conj(niw));diw=real(diw*conj(diw));
modul_d=derivat(niw/diw);w=roots(modul_d(2));

// get extreme points
k=find(imag(w)==0&real(w)>=0)
if k==[] then fr=[],g=[],return,end
w=real(w(k))

//find maximums
wx=maxi(w)+0.5
if horner(modul_d,wx)<0 then
  w=w($:-2:1)
else
  w=w($-1:-2:1)
end
fr=w/(2*%pi)
endfunction