Previous Next Contents

7  Signal Processing toolbox

7.1   %asn elliptic integral




CALLING SEQUENCE :

[y]=%asn(x,m)



PARAMETERS :




DESCRIPTION :

Calculates the elliptic integral
 y = integral from 0 to x of [1/(((1-t*t)^(1/2))(1-m*t*t)^(1/2))]
If x is a vector, y is a vector of same dimension as x.


EXAMPLE :

m=0.8;z=%asn(1/sqrt(m),m);K=real(z);Ktilde=imag(z);
x2max=1/sqrt(m);
x1=0:0.05:1;x2=1:((x2max-1)/20):x2max;x3=x2max:0.05:10;
x=[x1,x2,x3];
y=%asn(x,m);
rect=[0,-Ktilde,1.1*K,2*Ktilde];
plot2d(real(y)',imag(y)',1,'011',' ',rect)
//
deff('y=f(t)','y=1/sqrt((1-t^2)*(1-m*t^2))');
intg(0,0.9,f)-%asn(0.9,m)  //Works for real case only!



Author : F. D.



7.2   %k Jacobi's complete elliptic integral




CALLING SEQUENCE :

[K]=%k(m)



PARAMETERS :




DESCRIPTION :

Calculates Jacobi's complete elliptic integral of the first kind :
K = integral from 0 to 1 of [(1-t^2)(1-m*t^2)]**(-1/2)



EXAMPLE :

m=0.4;
%asn(1,m)
%k(m)



REFERENCES :

Abramowitz and Stegun page 598


See Also : %asn X


Author : F.D.



7.3   %sn Jacobi 's elliptic function




CALLING SEQUENCE :

[y]=%sn(x,m)



PARAMETERS :




DESCRIPTION :

Jacobi 's sn elliptic function with parameter m: the inverse of the elliptic integral for the parameter m.

The amplitude am is computed in fortran and the addition formulas for elliptic functions are applied


EXAMPLE :

m=0.36;
K=%k(m);
P=4*K; //Real period
real_val=0:(P/50):P;
plot(real_val,real(%sn(real_val,m)))
xbasc();
KK=%k(1-m);
Ip=2*KK;
ima_val1=0:(Ip/50):KK-0.001;
ima_val2=(KK+0.05):(Ip/25):(Ip+KK);
z1=%sn(%i*ima_val1,m);z2=%sn(%i*ima_val2,m);
plot2d([ima_val1',ima_val2'],[imag(z1)',imag(z2)']);
xgrid(3)



See Also : %asn X, %k X


Author : F. D.



7.4   Signal Signal manual description




FILTERS :




SPECTRAL ESTIMATION :




TRANSFORMS :




IDENTIFICATION :




MISCELLANEOUS :

7.5   analpf create analog low-pass filter




CALLING SEQUENCE :

[hs,pols,zers,gain]=analpf(n,fdesign,rp,omega)



PARAMETERS :




DESCRIPTION :

Creates analog low-pass filter with cut-off frequency at omega.

hs=gain*poly(zers,'s')/poly(pols,'s')



EXAMPLE :

//Evaluate magnitude response of continuous-time system 
hs=analpf(4,'cheb1',[.1 0],5)
fr=0:.1:15;
hf=freq(hs(2),hs(3),%i*fr);
hm=abs(hf);
plot(fr,hm)



Author : C. B.



7.6   buttmag response of Butterworth filter




CALLING SEQUENCE :

[h]=buttmag(order,omegac,sample)



PARAMETERS :




DESCRIPTION :

squared magnitude response of a Butterworth filter omegac = cutoff frequency ; sample = sample of frequencies


EXAMPLE :

//squared magnitude response of Butterworth filter
h=buttmag(13,300,1:1000);
mag=20*log(h)'/log(10);
plot2d((1:1000)',mag,[2],"011"," ",[0,-180,1000,20])



Author : F. D.



7.7   casc cascade realization of filter from coefficients




CALLING SEQUENCE :

[cels]=casc(x,z)



PARAMETERS :




DESCRIPTION :

Creates cascade realization of filter from a matrix of coefficients (utility function).


EXAMPLE :

x=[1,2,3;4,5,6;7,8,9;10,11,12]
cels=casc(x,'z')

7.8   cepstrum cepstrum calculation




CALLING SEQUENCE :

fresp = cepstrum(w,mag)



PARAMETERS :




DESCRIPTION :

fresp = cepstrum(w,mag) returns a frequency response fresp(i) whose magnitude at frequency w(i) equals mag(i) and such that the phase of freq corresponds to a stable and minimum phase system. w needs not to be sorted, but minimal entry should not be close to zero and all the entries of w should be different.


EXAMPLE :

w=0.1:0.1:5;mag=1+abs(sin(w));
fresp=cepstrum(w,mag);
plot2d([w',w'],[mag(:),abs(fresp)])



See Also : frfit X



7.9   cheb1mag response of Chebyshev type 1 filter




CALLING SEQUENCE :

[h2]=cheb1mag(n,omegac,epsilon,sample)



PARAMETERS :




DESCRIPTION :

Square magnitude response of a type 1 Chebyshev filter.

omegac
=passband edge.

epsilon
: such that 1/(1+epsilon^2)=passband ripple.

sample
: vector of frequencies where the square magnitude is desired.


EXAMPLE :

//Chebyshev; ripple in the passband
n=13;epsilon=0.2;omegac=3;sample=0:0.05:10;
h=cheb1mag(n,omegac,epsilon,sample);
plot(sample,h,'frequencies','magnitude')



See Also : buttmag X



7.10   cheb2mag response of type 2 Chebyshev filter




CALLING SEQUENCE :

[h2]=cheb2mag(n,omegar,A,sample)



PARAMETERS :




DESCRIPTION :

Square magnitude response of a type 2 Chebyshev filter.

omegar
= stopband edge, sample = vector of frequencies where the square magnitude h2 is desired.


EXAMPLE :

//Chebyshev; ripple in the stopband
n=10;omegar=6;A=1/0.2;sample=0.0001:0.05:10;
h2=cheb2mag(n,omegar,A,sample);
plot(sample,log(h2)/log(10),'frequencies','magnitude in dB')
//Plotting of frequency edges
minval=(-maxi(-log(h2)))/log(10);
plot2d([omegar;omegar],[minval;0],[2],"000");
//Computation of the attenuation in dB at the stopband edge
attenuation=-log(A*A)/log(10);
plot2d(sample',attenuation*ones(sample)',[5],"000")



See Also : cheb1mag X



7.11   chepol Chebychev polynomial




CALLING SEQUENCE :

[Tn]=chepol(n,var)



PARAMETERS :




DESCRIPTION :

Recursive implementation of Chebychev polynomial. Tn=2*poly(0,var)*chepol(n-1,var)-chepol(n-2,var) with T0=1 and T1=poly(0,var).


EXAMPLE :

chepol(4,'x')



Author : F. D.



7.12   convol convolution




CALLING SEQUENCE :

[y]=convol(h,x)
[y,e1]=convol(h,x,e0)



PARAMETERS :




DESCRIPTION :

calculates the convolution y= h*x of two discrete sequences by using the fft. Overlap add method can be used.

USE OF OVERLAP ADD METHOD: For x=[x1,x2,...,xNm1,xN] First call is [y1,e1]=convol(h,x1); Subsequent calls : [yk,ek]=convol(h,xk,ekm1); Final call : [yN]=convol(h,xN,eNm1); Finally y=[y1,y2,...,yNm1,yN]


EXAMPLE :

x=1:3;
h1=[1,0,0,0,0];h2=[0,1,0,0,0];h3=[0,0,1,0,0];
x1=convol(h1,x),x2=convol(h2,x),x3=convol(h3,x),
convol(h1+h2+h3,x)
p1=poly(x,'x','coeff')
p2=poly(h1+h2+h3,'x','coeff')
p1*p2



See Also : corr X, fft X, pspect X


Author : F. D , C. Bunks Date 3 Oct. 1988



7.13   corr correlation, covariance




CALLING SEQUENCE :

[cov,Mean]=corr(x,[y],nlags)
[cov,Mean]=corr('fft',xmacro,[ymacro],n,sect)

[w,xu]=corr('updt',x1,[y1],w0)
[w,xu]=corr('updt',x2,[y2],w,xu)
 ...
[wk]=corr('updt',xk,[yk],w,xu)



PARAMETERS :




DESCRIPTION :

Computes
                n - m 
                 ====
                 \\                                                 1
        cov(m) =  >        (x(k)  - xmean) (y(m+k)      - ymean) * ---
                 /                                                  n
                 ====
                 k = 1
cov(m) = 1/n
n-m
S
1
(x(k) - E(x)) (y(m+k) - E(y))
for m=0,..,nlag-1 and two vectors x=[x(1),..,x(n)] y=[y(1),..,y(n)]

Note that if x and y sequences are differents corr(x,y,...) is different with corr(y,x,...)

Short sequences:

[cov,Mean]=corr(x,[y],nlags) returns the first nlags correlation coefficients and Mean = mean(x) (mean of [x,y] if y is an argument). The sequence x (resp. y) is assumed real, and x and y are of same dimension n.

Long sequences:

[cov,Mean]=corr('fft',xmacro,[ymacro],n,sect)

Here xmacro
is either "Updating method":
[w,xu]=corr('updt',x1,[y1],w0)
[w,xu]=corr('updt',x2,[y2],w,xu)
 ...
wk=corr('updt',xk,[yk],w,xu)
With this calling sequence the calculation is updated at each call to corr.
w0 = 0*ones(1,2*nlags);
nlags = power of 2.
x1,x2,... are parts of x such that x=[x1,x2,...] and sizes of xi a power of 2. To get nlags coefficients a final fft must be performed c=fft(w,1)/n; cov=c(1nlags) (n is the size of x (y)). Caution: this calling sequence assumes that xmean = ymean = 0.


EXAMPLE :

x=%pi/10:%pi/10:102.4*%pi;
rand('seed');rand('normal');
y=[.8*sin(x)+.8*sin(2*x)+rand(x);.8*sin(x)+.8*sin(1.99*x)+rand(x)];
c=[];
for j=1:2,for k=1:2,c=[c;corr(y(k,:),y(j,:),64)];end;end;
c=matrix(c,2,128);cov=[];
for j=1:64,cov=[cov;c(:,(j-1)*2+1:2*j)];end;
rand('unif')
//
rand('normal');x=rand(1,256);y=-x;
deff('[z]=xx(inc,is)','z=x(is:is+inc-1)');
deff('[z]=yy(inc,is)','z=y(is:is+inc-1)');
[c,mxy]=corr(x,y,32);
x=x-mxy(1)*ones(x);y=y-mxy(2)*ones(y);  //centring
c1=corr(x,y,32);c2=corr(x,32);
norm(c1+c2,1)
[c3,m3]=corr('fft',xx,yy,256,32);
norm(c1-c3,1)
[c4,m4]=corr('fft',xx,256,32);
norm(m3,1),norm(m4,1)
norm(c3-c1,1),norm(c4-c2,1)
x1=x(1:128);x2=x(129:256);
y1=y(1:128);y2=y(129:256);
w0=0*ones(1:64);   //32 coeffs
[w1,xu]=corr('u',x1,y1,w0);w2=corr('u',x2,y2,w1,xu);
zz=real(fft(w2,1))/256;c5=zz(1:32);
norm(c5-c1,1)
[w1,xu]=corr('u',x1,w0);w2=corr('u',x2,w1,xu);
zz=real(fft(w2,1))/256;c6=zz(1:32);
norm(c6-c2,1)
rand('unif')
// test for Fortran or C external 
//
deff('[y]=xmacro(sec,ist)','y=sin(ist:(ist+sec-1))');
x=xmacro(100,1);
[cc1,mm1]=corr(x,2^3);
[cc,mm]=corr('fft',xmacro,100,2^3);
[cc2,mm2]=corr('fft','corexx',100,2^3);
[maxi(abs(cc-cc1)),maxi(abs(mm-mm1)),maxi(abs(cc-cc2)),maxi(abs(mm-mm2))]

deff('[y]=ymacro(sec,ist)','y=cos(ist:(ist+sec-1))');
y=ymacro(100,1);
[cc1,mm1]=corr(x,y,2^3);
[cc,mm]=corr('fft',xmacro,ymacro,100,2^3);
[cc2,mm2]=corr('fft','corexx','corexy',100,2^3);
[maxi(abs(cc-cc1)),maxi(abs(mm-mm1)),maxi(abs(cc-cc2)),maxi(abs(mm-mm2))]




See Also : fft X



7.14   cspect spectral estimation (periodogram method)




CALLING SEQUENCE :

[sm,cwp]=cspect(nlags,ntp,wtype,x,y,wpar)



PARAMETERS :




DESCRIPTION :

Spectral estimation using the modified periodogram method. Cross-spectral estimate of x and y is calculated when both x and y are given. Auto-spectral estimate of x is calculated if y is not given.


EXAMPLE :

rand('normal');rand('seed',0);
x=rand(1:1024-33+1);
//make low-pass filter with eqfir
nf=33;bedge=[0 .1;.125 .5];des=[1 0];wate=[1 1];
h=eqfir(nf,bedge,des,wate);
//filter white data to obtain colored data 
h1=[h 0*ones(1:maxi(size(x))-1)];
x1=[x 0*ones(1:maxi(size(h))-1)];
hf=fft(h1,-1);   xf=fft(x1,-1);yf=hf.*xf;y=real(fft(yf,1));
sm=cspect(100,200,'tr',y);
smsize=maxi(size(sm));fr=(1:smsize)/smsize;
plot(fr,log(sm))



See Also : pspect X


Author : C. Bunks



7.15   czt chirp z-transform algorithm




CALLING SEQUENCE :

[czx]=czt(x,m,w,phi,a,theta)



PARAMETERS :




DESCRIPTION :

chirp z-transform algorithm which calcultes the z-transform on a spiral in the z-plane at the points

[a*exp(j*theta)][w^kexp(j*k*phi)] for k=0,1,...,m-1.


EXAMPLE :

a=.7*exp(%i*%pi/6);
[ffr,bds]=xgetech(); //preserve current context
rect=[-1.2,-1.2*sqrt(2),1.2,1.2*sqrt(2)];
t=2*%pi*(0:179)/179;xsetech([0,0,0.5,1]);
plot2d(sin(t)',cos(t)',[2],"012",' ',rect)
plot2d([0 real(a)]',[0 imag(a)]',[3],"000")
xsegs([-1.0,0;1.0,0],[0,-1.0;0,1.0])
w0=.93*exp(-%i*%pi/15);w=exp(-(0:9)*log(w0));z=a*w;
zr=real(z);zi=imag(z);
plot2d(zr',zi',[5],"000")
xsetech([0.5,0,0.5,1]);
plot2d(sin(t)',cos(t)',[2],"012",' ',rect)
plot2d([0 real(a)]',[0 imag(a)]',[-1],"000")
xsegs([-1.0,0;1.0,0],[0,-1.0;0,1.0])
w0=w0/(.93*.93);w=exp(-(0:9)*log(w0));z=a*w;
zr=real(z);zi=imag(z);
plot2d(zr',zi',[5],"000")
xsetech(ffr,bds); //restore context



Author : C. Bunks



7.16   dft discrete Fourier transform




CALLING SEQUENCE :

[xf]=dft(x,flag);



PARAMETERS :




DESCRIPTION :

Function which computes dft of vector x.


EXAMPLE :

n=8;omega = exp(-2*%pi*%i/n);
j=0:n-1;F=omega.^(j'*j);  //Fourier matrix
x=1:8;x=x(:);
F*x
fft(x,-1)
dft(x,-1)
inv(F)*x
fft(x,1)
dft(x,1)



See Also : fft X


Author : C. B.



7.17   ell1mag magnitude of elliptic filter




CALLING SEQUENCE :

[v]=ell1mag(eps,m1,z)



PARAMETERS :




DESCRIPTION :

Function used for squared magnitude of an elliptic filter. Usually m1=eps*eps/(a*a-1). Returns v=real(ones(z)./(ones(z)+eps*eps*s.*s)) for s=%sn(z,m1).


EXAMPLE :

deff('[alpha,beta]=alpha_beta(n,m,m1)',...
'if 2*int(n/2)=n then, beta=K1; else, beta=0;end;...
alpha=%k(1-m1)/%k(1-m);')
epsilon=0.1;A=10;  //ripple parameters
m1=(epsilon*epsilon)/(A*A-1);n=5;omegac=6;
m=find_freq(epsilon,A,n);omegar = omegac/sqrt(m)
%k(1-m1)*%k(m)/(%k(m1)*%k(1-m))-n   //Check...
[alpha,beta]=alpha_beta(n,m,m1)
alpha*%asn(1,m)-n*%k(m1)      //Check
sample=0:0.01:20;
//Now we map the positive real axis into the contour...
z=alpha*%asn(sample/omegac,m)+beta*ones(sample);
plot(sample,ell1mag(epsilon,m1,z))



See Also : buttmag X



7.18   eqfir minimax approximation of FIR filter




CALLING SEQUENCE :

[hn]=eqfir(nf,bedge,des,wate)



PARAMETERS :




DESCRIPTION :

Minimax approximation of multi-band, linear phase, FIR filter


EXAMPLE :

hn=eqfir(33,[0 .2;.25 .35;.4 .5],[0 1 0],[1 1 1]);
[hm,fr]=frmag(hn,256);
plot(fr,hm),



Author : C. B.



7.19   eqiir Design of iir filters




CALLING SEQUENCE :

[cells,fact,zzeros,zpoles]=eqiir(ftype,approx,om,deltap,deltas)



PARAMETERS :




DESCRIPTION :

Design of iir filter interface with eqiir (syredi)

The filter obtained is h(z)=fact
*product of the elements of cells.

That is hz=fact*prod(cells(2))./prod(cells(3))



EXAMPLE :

[cells,fact,zzeros,zpoles]=...
eqiir('lp','ellip',[2*%pi/10,4*%pi/10],0.02,0.001)
transfer=fact*poly(zzeros,'z')/poly(zpoles,'z')



See Also : eqfir X, iir X



7.20   faurre filter




CALLING SEQUENCE :

[Pn,Rt,T]=faurre(n,H,F,G,r0)



PARAMETERS :




DESCRIPTION :

function which computes iteratively the minimal solution of the algebraic Riccati equation and gives the matrices Rt and Tt of the filter model.


Author : G. Le V.



7.21   ffilt coefficients of FIR low-pass




CALLING SEQUENCE :

[x]=ffilt(ft,n,fl,fh)



PARAMETERS :




DESCRIPTION :

Get n coefficients of a FIR low-pass, high-pass, band-pass, or stop-band filter. For low and high-pass filters one cut-off frequency must be specified whose value is given in fl. For band-pass and stop-band filters two cut-off frequencies must be specified for which the lower value is in fl and the higher value is in fh


Author : C. B.



7.22   fft fast Fourier transform.




CALLING SEQUENCE :

[x]=fft(a,-1)
[x]=fft(a,1)
x=fft(a,-1,dim,incr)
x=fft(a,1,dim,incr)



PARAMETERS :




DESCRIPTION :

Short syntax (one or two dimensional fft):

x=fft(a,-1) gives a direct transform (the -1 refers to the sign of the exponent..., NOT to "inverse"), that is x(k)=sum over m from 1 to n of a(m)*exp(-2i*pi*(m-1)*(k-1)/n) for k varying from 1 to n (n=size of vector a).

a=fft(x,1) performs the inverse transform normalized by 1/n.

(fft(fft(.,-1),1)
is identity).

When the first argument given to fft
is a matrix a two-dimensional FFT is performed.

Long syntax (multidimensional FFT):
x=fft(a,-1,dim,incr) allows to perform an multidimensional fft.

If a is a real or complex vector implicitly indexed by x1,x2,..,xp
i.e. a(x1,x2,..,xp) where x1 lies in 1..dim1, x2 in 1.. dim2,... one gets a p-dimensional FFT p by calling p times fft as follows
 a1=fft(a ,-1,dim1,incr1)
 a2=fft(a1,-1,dim2,incr2) ...
where dimi is the dimension of the current variable w.r.t which one is integrating and incri is the increment which separates two successive xi elements in a.

In particular,if a
is an nxm matrix, x=fft(a,-1) is equivalent to the two instructions:

a1=fft(a,-1,m,1)
and x=fft(a1,-1,n,m).

if a is an hypermatrix (see hypermat) fft(a,flag) performs the N dimensional fft of a.


EXAMPLE  :

a=[1;2;3];n=size(a,'*');
norm(1/n*exp(2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,1))
norm(exp(-2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,-1))  



See Also : corr X



7.23   filter modelling filter




CALLING SEQUENCE :

[y,xt]=filter(n,F,H,Rt,T)



PARAMETERS :




DESCRIPTION :

This function computes the modelling filter


See Also : faurre X


Author : G. Le V.



7.24   find_freq parameter compatibility for elliptic filter design




CALLING SEQUENCE :

[m]=find_freq(epsilon,A,n)



PARAMETERS :




DESCRIPTION :

Search for m such that n=K(1-m1)K(m)/(K(m1)K(1-m)) with

m1=(epsilon*epsilon)/(A*A-1)
;

If m = omegar^2/omegac^2
, the parameters epsilon,A,omegac,omegar and n are then compatible for defining a prototype elliptic filter. Here, K=%k(m) is the complete elliptic integral with parameter m.


See Also : %k X


Author : F. D.



7.25   findm for elliptic filter design




CALLING SEQUENCE :

[m]=findm(chi)



DESCRIPTION :

Search for m such that chi = %k(1-m)/%k(m) (For use with find_freq).


See Also : %k X


Author : F. D.



7.26   frfit frequency response fit




CALLING SEQUENCE :

sys=frfit(w,fresp,order)
[num,den]=frfit(w,fresp,order)
sys=frfit(w,fresp,order,weight)
[num,den]=frfit(w,fresp,order,weight)



PARAMETERS :




DESCRIPTION :

sys=frfit(w,fresp,order,weight) returns a bi-stable transfer function G(s)=sys=num/den, of of given order such that its frequency response G(w(i)) matches fresp(i), i.e. freq(num,den,%i*w) should be close to fresp. weight(i) is the weight given to w(i).


EXAMPLE :

w=0.01:0.01:2;s=poly(0,'s');
G=syslin('c',2*(s^2+0.1*s+2), (s^2+s+1)*(s^2+0.3*s+1));
fresp=repfreq(G,w);
Gid=frfit(w,fresp,4);
frespfit=repfreq(Gid,w);
bode(w,[fresp;frespfit])



See Also : frep2tf X, factors X, cepstrum X, mrfit X, freq X, calfrq X



7.27   frmag magnitude of FIR and IIR filters




CALLING SEQUENCE :

[xm,fr]=frmag(num[,den],npts)



PARAMETERS :




DESCRIPTION :

calculates the magnitude of the frequency responses of FIR and IIR filters. The filter description can be one or two vectors of coefficients, one or two polynomials, or a rational polynomial.


Author : C. B.



7.28   fsfirlin design of FIR, linear phase filters, frequency sampling technique




CALLING SEQUENCE :

[hst]=fsfirlin(hd,flag)



PARAMETERS :




DESCRIPTION :

function for the design of FIR, linear phase filters using the frequency sampling technique


Author : G. Le Vey


EXAMPLE :

//
//Example of how to use the fsfirlin macro for the design 
//of an FIR filter by a frequency sampling technique.
//
//Two filters are designed : the first (response hst1) with 
//abrupt transitions from 0 to 1 between passbands and stop 
//bands; the second (response hst2) with one sample in each 
//transition band (amplitude 0.5) for smoothing.
//
hd=[zeros(1,15) ones(1,10) zeros(1,39)];//desired samples
hst1=fsfirlin(hd,1);//filter with no sample in the transition
hd(15)=.5;hd(26)=.5;//samples in the transition bands
hst2=fsfirlin(hd,1);//corresponding filter
pas=1/prod(size(hst1))*.5;
fg=0:pas:.5;//normalized frequencies grid
plot2d([1 1].*.fg(1:257)',[hst1' hst2']);
// 2nd example
hd=[0*ones(1,15) ones(1,10) 0*ones(1,39)];//desired samples
hst1=fsfirlin(hd,1);//filter with no sample in the transition
hd(15)=.5;hd(26)=.5;//samples in the transition bands
hst2=fsfirlin(hd,1);//corresponding filter
pas=1/prod(size(hst1))*.5;
fg=0:pas:.5;//normalized frequencies grid
n=prod(size(hst1))
plot(fg(1:n),hst1);
plot2d(fg(1:n)',hst2',[3],"000");



See Also : ffilt X, wfir X



7.29   group group delay for digital filter




CALLING SEQUENCE :

[tg,fr]=group(npts,a1i,a2i,b1i,b2i)



PARAMETERS :




DESCRIPTION :

Calculate the group delay of a digital filter with transfer function h(z).

The filter specification can be in coefficient form, polynomial form, rational polynomial form, cascade polynomial form, or in coefficient polynomial form.

In the coefficient polynomial form the transfer function is formulated by the following expression

h(z)=prod(a1i+a2i*z+z**2)/prod(b1i+b2i*z+z^2)



EXAMPLE :

z=poly(0,'z');
h=z/(z-.5);
[tg,fr]=group(100,h);
plot(fr,tg)



Author : C. B.



7.30   hank covariance to hankel matrix




CALLING SEQUENCE :

[hk]=hank(m,n,cov)



PARAMETERS :




DESCRIPTION :

this function builds the hankel matrix of size (m*d,n*d) from the covariance sequence of a vector process


Author : G. Le Vey


EXAMPLE :

//Example of how to use the hank macro for 
//building a Hankel matrix from multidimensional 
//data (covariance or Markov parameters e.g.)
//
//This is used e.g. in the solution of normal equations
//by classical identification methods (Instrumental Variables e.g.)
//
//1)let's generate the multidimensional data under the form :
//  C=[c_0 c_1 c_2 .... c_n]
//where each bloc c_k is a d-dimensional matrix (e.g. the k-th correlation 
//of a d-dimensional stochastic process X(t) [c_k = E(X(t) X'(t+k)], ' 
//being the transposition in scilab)
//
//we take here d=2 and n=64
//
c=rand(2,2*64)
//
//generate the hankel matrix H (with 4 bloc-rows and 5 bloc-columns)
//from the data in c
//
H=hank(4,5,c);
//



See Also : toeplitz X



7.31   hilb Hilbert transform




CALLING SEQUENCE :

[xh]=hilb(n[,wtype][,par])



PARAMETERS :




DESCRIPTION :

returns the first n points of the Hilbert transform centred around the origin.

That is, xh=(2/(n*pi))*(sin(n*pi/2))^2
.


EXAMPLE :

plot(hilb(51))



Author : C. B.



7.32   iir iir digital filter




CALLING SEQUENCE :

[hz]=iir(n,ftype,fdesign,frq,delta)



PARAMETERS :




DESCRIPTION :

function which designs an iir digital filter using analog filter designs.


EXAMPLE :

hz=iir(3,'bp','ellip',[.15 .25],[.08 .03]);
[hzm,fr]=frmag(hz,256);
plot2d(fr',hzm')
xtitle('Discrete IIR filter band pass  0.15<fr<0.25 ',' ',' ');
q=poly(0,'q');     //to express the result in terms of the ...
hzd=horner(hz,1/q) //delay operator q=z^-1



See Also : eqfir X, eqiir X


Author : C. B.



7.33   iirgroup group delay Lp IIR filter optimization




CALLING SEQUENCE :

[lt,grad]=iirgroup(p,r,theta,omega,wt,td)
[cout,grad,ind]=iirlp(x,ind,p,[flag],lambda,omega,ad,wa,td,wt)



PARAMETERS :




DESCRIPTION :

optimization of IIR filters for the Lp criterium for the the group delay. (Rabiner & Gold pp270-273).



7.34   iirlp Lp IIR filter optimization




CALLING SEQUENCE :

[cost,grad,ind]=iirlp(x,ind,p,[flag],lambda,omega,ad,wa,td,wt)



PARAMETERS :




DESCRIPTION :

optimization of IIR filters for the Lp criterium for the amplitude and/or the group delay. (Rabiner & Gold pp270-273).



7.35   intdec Changes sampling rate of a signal




CALLING SEQUENCE :

[y]=intdec(x,lom)



PARAMETERS :




DESCRIPTION :

Changes the sampling rate of a 1D or 2D signal by the rates in lom


Author : C. B.



7.36   jmat row or column block permutation




CALLING SEQUENCE :

[j]=jmat(n,m)



PARAMETERS :




DESCRIPTION :

This function permutes block rows or block columns of a matrix



7.37   kalm Kalman update




CALLING SEQUENCE :

[x1,p1,x,p]=kalm(y,x0,p0,f,g,h,q,r)



PARAMETERS :




DESCRIPTION :

function which gives the Kalman update and error variance


Author : C. B.



7.38   lattn recursive solution of normal equations




CALLING SEQUENCE :

[la,lb]=lattn(n,p,cov)



PARAMETERS :




DESCRIPTION :

solves recursively on n (p being fixed) the following system (normal equations), i.e. identifies the AR part (poles) of a vector ARMA(n,p) process
                       |Rp+1 Rp+2 . . . . . Rp+n  |
                       |Rp   Rp+1 . . . . . Rp+n-1|
                       | .   Rp   . . . . .  .    |
                       |                          |
   |I -A1 -A2 . . .-An|| .    .   . . . . .  .    |=0
                       | .    .   . . . . .  .    |
                       | .    .   . . . . .  .    |
                       | .    .   . . . . . Rp+1  |
                       |Rp+1-n.   . . . . . Rp    |
where {Rk;k=1,nlag}is the sequence of empirical covariances


Author : G. Le V.



7.39   lattp lattp




CALLING SEQUENCE :

[la,lb]=lattp(n,p,cov)



DESCRIPTION :

see lattn


Author : G.Levey



7.40   lev Yule-Walker equations (Levinson's algorithm)




CALLING SEQUENCE :

[ar,sigma2,rc]=lev(r)



PARAMETERS :




DESCRIPTION :

resolve the Yule-Walker equations
      |R(0)   R(1)   ... R(N-1)|| ar(1) | |sigma2|
      |R(1)   R(0)   ... R(N-2)|| ar(2) | |  0   |
      |  :      :    ...    :  ||   :   |=|  0   |
      |  :      :    ...    :  ||   :   | |  0   |
      |R(N-1) R(N-2) ...  R(0) ||ar(N-1)| |  0   |
where
       R(i)=r(i-1)

using Levinson's algorithm.


Author : C. B.



7.41   levin Toeplitz system solver by Levinson algorithm (multidimensional)




CALLING SEQUENCE :

[la,sig]=levin(n,cov)



PARAMETERS :




DESCRIPTION :

function which solves recursively on n the following Toeplitz system (normal equations)
                |R1   R2   . . . Rn  |
                |R0   R1   . . . Rn-1|
                |R-1  R0   . . . Rn-2|
                | .    .   . . .  .  |
|I -A1 .. -An|  | .    .   . . .  .  | = 0
                | .    .   . . .  .  |
                | .    .   . . .  .  |
                |R2-n R3-n . . . R1  |
                |R1-n R2-n . . . R0  |
where {Rk;k=1,nlag}is the sequence of nlag empirical covariances


Author : G. Le Vey


EXAMPLE :

//We use the 'levin' macro for solving the normal equations 
//on two examples: a one-dimensional and a two-dimensional process.
//We need the covariance sequence of the stochastic process.
//This example may usefully be compared with the results from 
//the 'phc' macro (see the corresponding help and example in it)
//
//
//1) A one-dimensional process
//   -------------------------
//
//We generate the process defined by two sinusoids (1Hz and 2 Hz) 
//in additive Gaussian noise (this is the observed process); 
//the simulated process is sampled at 10 Hz (step 0.1 in t, underafter).
//
t1=0:.1:100;rand('normal');
y1=sin(2*%pi*t1)+sin(2*%pi*2*t1);y1=y1+rand(y1);plot(t1,y1);
//
//covariance of y1
//
nlag=128;
c1=corr(y1,nlag);
c1=c1';//c1 needs to be given columnwise (see the section PARAMETERS of this help)
//
//compute the filter for a maximum order of n=10
//la is a list-type variable each element of which 
//containing the filters of order ranging from 1 to n; (try varying n)
//in the d-dimensional case this is a matrix polynomial (square, d X d)
//sig gives, the same way, the mean-square error
//
n=15;
[la1,sig1]=levin(n,c1);
//
//verify that the roots of 'la' contain the 
//frequency spectrum of the observed process y
//(remember that y is sampled -in our example 
//at 10Hz (T=0.1s) so that we need to retrieve 
//the original frequencies (1Hz and 2 Hz) through 
//the log and correct scaling by the frequency sampling)
//we verify this for each filter order
//
for i=1:n, s1=roots(la1(i));s1=log(s1)/2/%pi/.1;
//
//now we get the estimated poles (sorted, positive ones only !)
//
s1=sort(imag(s1));s1=s1(1:i/2);end;
//
//the last two frequencies are the ones really present in the observed 
//process ---> the others are "artifacts" coming from the used model size.
//This is related to the rather difficult problem of order estimation.
//
//2) A 2-dimensional process 
//   -----------------------
//(4 frequencies 1, 2, 3, and 4 Hz, sampled at 0.1 Hz :
//   |y_1|        y_1=sin(2*Pi*t)+sin(2*Pi*2*t)+Gaussian noise
// y=|   | with : 
//   |y_2|        y_2=sin(2*Pi*3*t)+sin(2*Pi*4*t)+Gaussian noise
//
//
d=2;dt=0.1;
nlag=64;
t2=0:2*%pi*dt:100;
y2=[sin(t2)+sin(2*t2)+rand(t2);sin(3*t2)+sin(4*t2)+rand(t2)];
c2=[];
for j=1:2, for k=1:2, c2=[c2;corr(y2(k,:),y2(j,:),nlag)];end;end;
c2=matrix(c2,2,128);cov=[];
for j=1:64,cov=[cov;c2(:,(j-1)*d+1:j*d)];end;//covar. columnwise
c2=cov;
//
//in the multidimensional case, we have to compute the 
//roots of the determinant of the matrix polynomial 
//(easy in the 2-dimensional case but tricky if d>=3 !). 
//We just do that here for the maximum desired 
//filter order (n); mp is the matrix polynomial of degree n
//
[la2,sig2]=levin(n,c2);
mp=la2(n);determinant=mp(1,1)*mp(2,2)-mp(1,2)*mp(2,1);
s2=roots(determinant);s2=log(s2)/2/%pi/0.1;//same trick as above for 1D process
s2=sort(imag(s2));s2=s2(1:d*n/2);//just the positive ones !
//
//There the order estimation problem is seen to be much more difficult !
//many artifacts ! The 4 frequencies are in the estimated spectrum 
//but beneath many non relevant others.
//



See Also : phc X



7.42   lgfft utility for fft




CALLING SEQUENCE :

[y]=lgfft(x)



PARAMETERS :




DESCRIPTION :

returns the lowest power of 2 larger than size(x) (for FFT use).



7.43   lindquist Lindquist's algorithm




CALLING SEQUENCE :

[Pn,Rt,T]=lindquist(n,H,F,G,r0)



PARAMETERS :




DESCRIPTION :

computes iteratively the minimal solution of the algebraic Riccati equation and gives the matrices Rt and Tt of the filter model, by the Lindquist's algorithm.


Author : G. Le V.



7.44   mese maximum entropy spectral estimation




CALLING SEQUENCE :

[sm,fr]=mese(x [,npts]);



PARAMETERS :




DESCRIPTION :

Calculate the maximum entropy spectral estimate of x


Author : C. B.



7.45   mfft multi-dimensional fft




CALLING SEQUENCE :

[xk]=mfft(x,flag,dim)



PARAMETERS :




DESCRIPTION :

FFT for a multi-dimensional signal

For example for a three dimensional vector which has three points along its first dimension, two points along its second dimension and three points along its third dimension the row vector is arranged as follows
     x=[x(1,1,1),x(2,1,1),x(3,1,1),
        x(1,2,1),x(2,2,1),x(3,2,1),
              x(1,1,2),x(2,1,2),x(3,1,2),
              x(1,2,2),x(2,2,2),x(3,2,2),
                    x(1,1,3),x(2,1,3),x(3,1,3),
                    x(1,2,3),x(2,2,3),x(3,2,3)]
and the dim vector is: dim=[3,2,3]


Author : C. B.



7.46   mrfit frequency response fit




CALLING SEQUENCE :

sys=mrfit(w,mag,order)
[num,den]=mrfit(w,mag,order)
sys=mrfit(w,mag,order,weight)
[num,den]=mrfit(w,mag,order,weight)



PARAMETERS :




DESCRIPTION :

sys=mrfit(w,mag,order,weight) returns a bi-stable transfer function G(s)=sys=num/den, of of given order such that its frequency response magnitude abs(G(w(i))) matches mag(i) i.e. abs(freq(num,den,%i*w)) should be close to mag. weight(i) is the weigth given to w(i).


EXAMPLE :

w=0.01:0.01:2;s=poly(0,'s');
G=syslin('c',2*(s^2+0.1*s+2),(s^2+s+1)*(s^2+0.3*s+1)); // syslin('c',Num,Den);
fresp=repfreq(G,w);
mag=abs(fresp);
Gid=mrfit(w,mag,4);
frespfit=repfreq(Gid,w);
plot2d([w',w'],[mag(:),abs(frespfit(:))])



See Also : cepstrum X, frfit X, freq X, calfrq X



7.47   phc Markovian representation




CALLING SEQUENCE :

[H,F,G]=phc(hk,d,r)



PARAMETERS :




DESCRIPTION :

Function which computes the matrices H, F, G of a Markovian representation by the principal hankel component approximation method, from the hankel matrix built from the covariance sequence of a stochastic process.


EXAMPLE :

//
//This example may usefully be compared with the results from 
//the 'levin' macro (see the corresponding help and example)
//
//We consider the process defined by two sinusoids (1Hz and 2 Hz) 
//in additive Gaussian noise (this is the observation); 
//the simulated process is sampled at 10 Hz.
//
t=0:.1:100;rand('normal');
y=sin(2*%pi*t)+sin(2*%pi*2*t);y=y+rand(y);plot(t,y)
//
//covariance of y
//
nlag=128;
c=corr(y,nlag);
//
//hankel matrix from the covariance sequence
//(we can choose to take more information from covariance
//by taking greater n and m; try it to compare the results !
//
n=20;m=20;
h=hank(n,m,c);
//
//compute the Markov representation (mh,mf,mg)
//We just take here a state dimension equal to 4 :
//this is the rather difficult problem of estimating the order !
//Try varying ns ! 
//(the observation dimension is here equal to one)
ns=4;
[mh,mf,mg]=phc(h,1,ns);
//
//verify that the spectrum of mf contains the 
//frequency spectrum of the observed process y
//(remember that y is sampled -in our example 
//at 10Hz (T=0.1s) so that we need 
//to retrieve the original frequencies through the log 
//and correct scaling by the frequency sampling)
//
s=spec(mf);s=log(s);
s=s/2/%pi/.1;
//
//now we get the estimated spectrum
imag(s),
//



See Also : levin X



7.48   pspect cross-spectral estimate between 2 series




CALLING SEQUENCE :

[sm,cwp]=pspect(sec_step,sec_leng,wtype,x,y,wpar)



PARAMETERS :




DESCRIPTION :

Cross-spectral estimate between x and y if both are given and auto-spectral estimate of x otherwise. Spectral estimate obtained using the modified periodogram method.


EXAMPLE :

rand('normal');rand('seed',0);
x=rand(1:1024-33+1);
//make low-pass filter with eqfir
nf=33;bedge=[0 .1;.125 .5];des=[1 0];wate=[1 1];
h=eqfir(nf,bedge,des,wate);
//filter white data to obtain colored data 
h1=[h 0*ones(1:maxi(size(x))-1)];
x1=[x 0*ones(1:maxi(size(h))-1)];
hf=fft(h1,-1);   xf=fft(x1,-1);yf=hf.*xf;y=real(fft(yf,1));
//plot magnitude of filter
//h2=[h 0*ones(1:968)];hf2=fft(h2,-1);hf2=real(hf2.*conj(hf2));
//hsize=maxi(size(hf2));fr=(1:hsize)/hsize;plot(fr,log(hf2));
//pspect example
sm=pspect(100,200,'tr',y);smsize=maxi(size(sm));fr=(1:smsize)/smsize;
plot(fr,log(sm));
rand('unif');



See Also : cspect X


Author : C. B.



7.49   remez Remez's algorithm




CALLING SEQUENCE :

[an]=remez(nc,fg,ds,wt)



PARAMETERS :




DESCRIPTION :

minimax approximation of a frequency domain magnitude response. The approximation takes the form
 h = sum[a(n)*cos(wn)]
for n=0,1,...,nc. An FIR, linear-phase filter can be obtained from the the output of remez by using the following commands:
                 hn(1nc-1)=an(nc-12)/2;
                 hn(nc)=an(1);
                 hn(nc+12*nc-1)=an(2nc)/2;
where an = cosine filter coefficients


See Also : remezb X



7.50   remezb Minimax approximation of magnitude response




CALLING SEQUENCE :

[an]=remezb(nc,fg,ds,wt)



PARAMETERS :




DESCRIPTION :

Minimax approximation of a frequency domain magnitude response. The approximation takes the form h = sum[a(n)*cos(wn)] for n=0,1,...,nc. An FIR, linear-phase filter can be obtained from the the output of the function by using the following commands
         hn(1:nc-1)=an(nc:-1:2)/2;
         hn(nc)=an(1);
         hn(nc+1:2*nc-1)=an(2:nc)/2;



EXAMPLE :

// Choose the number of cosine functions and create a dense grid 
// in [0,.24) and [.26,.5)
nc=21;ngrid=nc*16;
fg=.24*(0:ngrid/2-1)/(ngrid/2-1);
fg(ngrid/2+1:ngrid)=fg(1:ngrid/2)+.26*ones(1:ngrid/2);
// Specify a low pass filter magnitude for the desired response
ds(1:ngrid/2)=ones(1:ngrid/2);
ds(ngrid/2+1:ngrid)=zeros(1:ngrid/2);
// Specify a uniform weighting function
wt=ones(fg);
// Run remezb
an=remezb(nc,fg,ds,wt)
// Make a linear phase FIR filter 
hn(1:nc-1)=an(nc:-1:2)/2;
hn(nc)=an(1);
hn(nc+1:2*nc-1)=an(2:nc)/2;
// Plot the filter's magnitude response
plot(.5*(0:255)/256,frmag(hn,256));
//////////////
// Choose the number of cosine functions and create a dense grid in [0,.5)
nc=21; ngrid=nc*16;
fg=.5*(0:(ngrid-1))/ngrid;
// Specify a triangular shaped magnitude for the desired response
ds(1:ngrid/2)=(0:ngrid/2-1)/(ngrid/2-1);
ds(ngrid/2+1:ngrid)=ds(ngrid/2:-1:1);
// Specify a uniform weighting function
wt=ones(fg);
// Run remezb
an=remezb(nc,fg,ds,wt)
// Make a linear phase FIR filter 
hn(1:nc-1)=an(nc:-1:2)/2;
hn(nc)=an(1);
hn(nc+1:2*nc-1)=an(2:nc)/2;
// Plot the filter's magnitude response
plot(.5*(0:255)/256,frmag(hn,256));



Author : C. B.


See Also : eqfir X



7.51   rpem RPEM estimation




CALLING SEQUENCE :

[w1,[v]]=rpem(w0,u0,y0,[lambda,[k,[c]]])



PARAMETERS :

If the time domain is (t0,t0+k-1) the u0 vector contains the inputs

u(t0),u(t0+1),..,u(t0+k-1)
and y0 the outputs

y(t0),y(t0+1),..,y(t0+k-1)



DESCRIPTION :

Recursive estimation of parameters in an ARMAX model. Uses Ljung-Soderstrom recursive prediction error method. Model considered is the following:
y(t)+a(1)*y(t-1)+...+a(n)*y(t-n)=
b(1)*u(t-1)+...+b(n)*u(t-n)+e(t)+c(1)*e(t-1)+...+c(n)*e(t-n)
The effect of this command is to update the estimation of unknown parameter theta=[a,b,c] with

a=[a(1),...,a(n)], b=[b(1),...,b(n)], c=[c(1),...,c(n)]
.


OPTIONAL PARAMETERS :

lambda=[lambda0,alfa,beta] evolves according to :
lambda(t)=alfa*lambda(t-1)+beta 
with lambda(0)=lambda0

k : contraction factor to be chosen close to 1 as convergence occurs.

k=[k0,mu,nu]
evolves according to:
k(t)=mu*k(t-1)+nu 
with k(0)=k0.

c
: large parameter.(c=1000 is the default value).


OUTPUT PARAMETERS: :



w1
: update for w0.

v
: sum of squared prediction errors on u0, y0.(optional).

In particular w1(1)
is the new estimate of theta. If a new sample u1, y1 is available the update is obtained by:

[w2,[v]]=rpem(w1,u1,y1,[lambda,[k,[c]]])
. Arbitrary large series can thus be treated.



7.52   sinc samples of sinc function




CALLING SEQUENCE :

[x]=sinc(n,fl)



PARAMETERS :




DESCRIPTION :

Calculate n samples of the function sin(2*pi*fl*t)/(pi*t) for t=-n/2:n/2 (i.e. centred around the origin).


EXAMPLE :

plot(sinc(100,0.1))



See Also : sincd X


Author : C. B.



7.53   sincd sinc function




CALLING SEQUENCE :

[s]=sincd(n,flag)



PARAMETERS :




DESCRIPTION :

function which calculates the function Sin(N*x)/Sin(x)


EXAMPLE :

plot(sincd(10,1)) 



Author : G. Le V.



7.54   srfaur square-root algorithm




CALLING SEQUENCE :

[p,s,t,l,rt,tt]=srfaur(h,f,g,r0,n,p,s,t,l)



PARAMETERS :




DESCRIPTION :

square-root algorithm for the algebraic Riccati equation.



7.55   srkf square root Kalman filter




CALLING SEQUENCE :

[x1,p1]=srkf(y,x0,p0,f,h,q,r)



PARAMETERS :




DESCRIPTION :

square root Kalman filter algorithm


Author : C. B.



7.56   sskf steady-state Kalman filter




CALLING SEQUENCE :

[xe,pe]=sskf(y,f,h,q,r,x0)



PARAMETERS :




DESCRIPTION :

steady-state Kalman filter


Author : C. B.



7.57   system observation update




CALLING SEQUENCE :

[x1,y]=system(x0,f,g,h,q,r)



PARAMETERS :




DESCRIPTION :

define system function which generates the next observation given the old state. System recursively calculated
     x1=f*x0+g*u
     y=h*x0+v
where u is distributed N(0,q) and v is distribute N(0,r).


Author : C. B.



7.58   trans low-pass to other filter transform




CALLING SEQUENCE :

hzt=trans(pd,zd,gd,tr_type,frq)



PARAMETERS :




DESCRIPTION :

function for transforming standardized low-pass filter into one of the following filters: low-pass, high-pass, band-pass, stop-band.


Author : C. Bunks



7.59   wfir linear-phase FIR filters




CALLING SEQUENCE :

[wft,wfm,fr]=wfir(ftype,forder,cfreq,wtype,fpar)



PARAMETERS :




DESCRIPTION :

Function which makes linear-phase, FIR low-pass, band-pass, high-pass, and stop-band filters using the windowing technique. Works interactively if called with no arguments.


Author : C. Bunks



7.60   wiener Wiener estimate




CALLING SEQUENCE :

[xs,ps,xf,pf]=wiener(y,x0,p0,f,g,h,q,r)



PARAMETERS :




DESCRIPTION :

function which gives the Wiener estimate using the forward-backward Kalman filter formulation


Author : C. B.



7.61   wigner 'time-frequency' wigner spectrum




CALLING SEQUENCE :

[tab]=wigner(x,h,deltat,zp)



PARAMETERS :




DESCRIPTION :

function which computes the 'time-frequency' wigner spectrum of a signal.



7.62   window symmetric window




CALLING SEQUENCE :

[win_l,cwp]=window(wtype,n,par)



PARAMETERS :




DESCRIPTION :

function which calculates symmetric window


Author : C. B.



7.63   yulewalk least-square filter design




CALLING SEQUENCE :

Hz = yulewalk(N,frq,mag) 



PARAMETERS :




DESCRIPTION :

Hz = yulewalk(N,frq,mag) finds the N-th order iir filter
                  n-1         n-2            
      B(z)   b(1)z     + b(2)z    + .... + b(n)
H(z)= ---- = ---------------------------------
                n-1       n-2
      A(z)    z   + a(2)z    + .... + a(n)
which matches the magnitude frequency response given by vectors frq and mag. Vectors frq and mag specify the frequency and magnitude of the desired frequency response. The frequencies in frq must be between 0.0 and 1.0, with 1.0 corresponding to half the sample rate. They must be in increasing order and start with 0.0 and end with 1.0.


EXAMPLE :

f=[0,0.4,0.4,0.6,0.6,1];H=[0,0,1,1,0,0];Hz=yulewalk(8,f,H);
fs=1000;fhz = f*fs/2;  
xbasc(0);xset('window',0);plot2d(fhz',H');
xtitle('Desired Frequency Response (Magnitude)')
[frq,repf]=repfreq(Hz,0:0.001:0.5);
xbasc(1);xset('window',1);plot2d(fs*frq',abs(repf'));
xtitle('Obtained Frequency Response (Magnitude)')

7.64   zpbutt Butterworth analog filter




CALLING SEQUENCE :

[pols,gain]=zpbutt(n,omegac)



PARAMETERS :




DESCRIPTION :

computes the poles of a Butterworth analog filter of order n and cutoff frequency omegac transfer function H(s) is calculated by H(s) = gain/real(poly(pols,'s'))


Author : F.D.



7.65   zpch1 Chebyshev analog filter




CALLING SEQUENCE :

[poles,gain]=zpch1(n,epsilon,omegac)



PARAMETERS :




DESCRIPTION :

Poles of a Type 1 Chebyshev analog filter. The transfer function is given by :
 H(s)=gain/poly(poles,'s')



Author : F.D.



7.66   zpch2 Chebyshev analog filter




CALLING SEQUENCE :

[zeros,poles,gain]=zpch2(n,A,omegar)



PARAMETERS :




DESCRIPTION :

Poles and zeros of a type 2 Chebyshev analog filter gain is the gain of the filter
H(s)=gain*poly(zeros,'s')/poly(poles,'s')



Author : F.D.



7.67   zpell lowpass elliptic filter




CALLING SEQUENCE :

[zeros,poles,gain]=zpell(epsilon,A,omegac,omegar)



PARAMETERS :




DESCRIPTION :

Poles and zeros of prototype lowpass elliptic filter. gain is the gain of the filter


See Also : ell1mag X, eqiir X


Author : F.D.





7.68   arma Scilab arma library




DESCRIPTION :




Author : J.P.C



7.69   armac Scilab description of an armax process




CALLING SEQUENCE :

[ar]=armac(a,b,d,ny,nu,sig)



PARAMETERS :




DESCRIPTION :

this function creates a description as a list of an ARMAX process
   A(z^-1)y= B(z^-1)u + D(z^-1)sig*e(t)



EXAMPLE :

 
a=[1,-2.851,2.717,-0.865].*.eye(2,2)
b=[0,1,1,1].*.[1;1];
d=[1,0.7,0.2].*.eye(2,2);
sig=eye(2,2);
ar=armac(a,b,d,2,1,sig)



See Also : arma X, armax X, armax1 X, arsimul X



7.70   armax armax identification




CALLING SEQUENCE :

[arc,la,lb,sig,resid]=armax(r,s,y,u,[b0f,prf])



PARAMETERS :




DESCRIPTION :

armax is used to identify the coefficients of a n-dimensional ARX process
 
   A(z^-1)y= B(z^-1)u + sig*e(t)
where e(t) is a n-dimensional white noise with variance I. sig an nxn matrix and A(z) and B(z):
A(z) = 1+a1*z+...+a_r*z^r; ( r=0 => A(z)=1)
B(z) = b0+b1*z+...+b_s z^s ( s=-1 => B(z)=0)
for the method see Eykhoff in trends and progress in system identification, page 96. with z(t)=[y(t-1),..,y(t-r),u(t),...,u(t-s)] and coef= [-a1,..,-ar,b0,...,b_s] we can write y(t)= coef* z(t) + sig*e(t) and the algorithm minimises sum_{t=1}^N ( [y(t)- coef'z(t)]^2) where t0=maxi(maxi(r,s)+1,1))).


EXAMPLE :

 
[arc,a,b,sig,resid]=armax(); // will gives an example in dimension 1



Author : J-Ph. Chancelier.


See Also : imrep2ss X, time_id X, arl2 X, armax X, frep2tf X



7.71   armax1 armax identification




CALLING SEQUENCE :

[a,b,d,sig,resid]=armax1(r,s,q,y,u,[b0f])



PARAMETERS :




DESCRIPTION :

armax1 is used to identify the coefficients of a 1-dimensional ARX process:
   A(z^-1)y= B(z^-1)u + D(z^-1)sig*e(t)
   e(t) is a 1-dimensional white noise with variance 1.
   A(z)= 1+a1*z+...+a_r*z^r; ( r=0 => A(z)=1)
   B(z)= b0+b1*z+...+b_s z^s ( s=-1 => B(z)=0)
   D(z)= 1+d1*z+...+d_q*z^q  ( q=0 => D(z)=1)
for the method, see Eykhoff in trends and progress in system identification) page 96. with z(t)=[y(t-1),..,y(t-r),u(t),..., u(t-s),e(t-1),...,e(t-q)] and coef= [-a1,..,-ar,b0,...,b_s,d1,...,d_q]' y(t)= coef'* z(t) + sig*e(t).

a sequential version of the AR estimation where e(t-i) is replaced by an estimated value is used (RLLS). With q=0 this method is exactly a sequential version of armax


Author : J.-Ph.C



7.72   arsimul armax simulation




CALLING SEQUENCE :

[z]=arsimul(a,b,d,sig,u,[up,yp,ep])
[z]=arsimul(ar,u,[up,yp,ep])



PARAMETERS :




DESCRIPTION :

simulation of an n-dimensional armax process A(z^-1) z(k)= B(z^-1)u(k) + D(z^-1)*sig*e(k)

A(z)= Id+a1*z+...+a_r*z^r; ( r=0 =
> A(z)=Id) B(z)= b0+b1*z+...+b_s z^s; ( s=-1 => B(z)=0) D(z)= Id+d1*z+...+d_t z^t; ( t=0 => D(z)=Id) z et e are in R^n et u in R^m


METHOD  :

a state-space representation is constructed and ode with the option "discret" is used to compute z


Author : J-Ph.C.



7.73   narsimul armax simulation ( using rtitr)




CALLING SEQUENCE :

[z]=narsimul(a,b,d,sig,u,[up,yp,ep])
[z]=narsimul(ar,u,[up,yp,ep])



DESCRIPTION :

ARMAX simulation. Same as arsimul but the method is different the simulation is made with rtitr


Author : J-Ph. Chancelier ENPC Cergrene



7.74   noisegen noise generation




CALLING SEQUENCE :

[]=noisegen(pas,Tmax,sig)



DESCRIPTION :

generates a Scilab function [b]=Noise(t) where Noise(t) is a piecewise constant function ( constant on [k*pas,(k+1)*pas] ). The value on each constant interval are random values from i.i.d Gaussian variables of standard deviation sig. The function is constant for t<=0 and t>=Tmax.


EXAMPLE :

noisegen(0.5,30,1.0);
x=-5:0.01:35;
y=feval(x,Noise);
plot(x,y);

7.75   odedi test of ode




CALLING SEQUENCE :

[]=odedi()



DESCRIPTION :

Simple tests of ode and arsimul. Tests the option 'discret' of ode



7.76   prbs_a pseudo random binary sequences generation




CALLING SEQUENCE :

[u]=prbs_a(n,nc,[ids])



DESCRIPTION :

generation of pseudo random binary sequences u=[u0,u1,...,u_(n-1)]; u takes values in {-1,1}and changes at most nc times its sign. ids can be used to fix the date at which u must change its sign ids is then an integer vector with values in [1:n].


EXAMPLE :

u=prbs_a(50,10);
plot2d2("onn",(1:50)',u',1,"151",' ',[0,-1.5,50,1.5]);

7.77   reglin Linear regression




CALLING SEQUENCE :

[a,b,sig]=reglin(x,y)



DESCRIPTION :

solve the regression problem y=a*x+ b in the least square sense. sig is the standard deviation of the residual. x and y are two matrices of size x(p,n) and y(q,n), so the estimator a is a matrix of size (q,p) and b is a vector of size (q,1)


EXAMPLE  :

// simulation of data for a(3,5) and b(3,1)
x=rand(5,100);
aa=testmatrix('magi',5);aa=aa(1:3,:);
bb=[9;10;11]
y=aa*x +bb*ones(1,100)+ 0.1*rand(3,100);
// identification 
[a,b,sig]=reglin(x,y);
maxi(abs(aa-a))
maxi(abs(bb-b))
// an other example : fitting a polynom 
f=1:100; x=[f.*f; f];
y= [ 2,3]*x+ 10*ones(f) + 0.1*rand(f);
[a,b]=reglin(x,y)

Previous Next Contents