summaryrefslogtreecommitdiff
path: root/macros/schurrc.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/schurrc.sci')
-rw-r--r--macros/schurrc.sci41
1 files changed, 27 insertions, 14 deletions
diff --git a/macros/schurrc.sci b/macros/schurrc.sci
index 0a5e6ce..98448d6 100644
--- a/macros/schurrc.sci
+++ b/macros/schurrc.sci
@@ -3,28 +3,41 @@
//[K,E] = SCHURRC(R) returns the prediction error variance E. If R is a matrix, SCHURRC finds the error for each column of R, and returns them in the rows of E.
//Modified to match matlab i/p and o/p and handle exceptions
//Fixed bugs
-//by Debdeep Dey
+//by Debdeep Dey
+
+//////EXAMPLES:
+//m=linspace(1,100);
+//r = xcorr(m(1:5),'unbiased');.......autocorrelation vector
+//[k,e] = schurrc(r(5:$))
+
+//EXPECTED OUTPUT
+//e =1.6212406
+ //k = - 0.9090909 0.2222222 0.2244898 0.2434211
+
+
+
+
function [k,e] = schurrc(R)
narginchk(1,1,argn(2));
-if(type(R)==10) then
+if(type(R)==10) then// R is a matrix of character strings
w=R;
[nr,nc]=size(R);
if(nr==1 & nc==1) then
- R=ascii(R);
- R=matrix(R,length(w));
+ R=ascii(R);//conversion to the corresponding asci values
+ R=matrix(R,length(w));//reshaping the matrix
else
-
+
R=ascii(R);
- R=matrix(R,size(w));
+ R=matrix(R,size(w));//reshaping the matrix
end
-
+
end
-if(type(R) > 1) then
+if(type(R) > 1) then ///checking if R in not a matrix of real or complex numbers
error('Input R is not a matrix')
end
-if (min(size(R)) == 1) then
- R = R(:);
-end
+if (min(size(R)) == 1) then
+ R = R(:);
+end
[m,n] = size(R);
// Compute reflection coefficients for each column of the input matrix
for j = 1:n
@@ -33,11 +46,11 @@ for j = 1:n
U = [0 X(2:m); X(1:m)];
for i = 2:m,
- U(2,:) = [0 U(2,1:m-1)];
- k(i-1,j) = -U(1,i)/U(2,i);
+ U(2,:) = [0 U(2,1:m-1)];
+ k(i-1,j) = -U(1,i)/U(2,i);
U = [1 k(i-1,j); conj(k(i-1,j)) 1]*U;
end
-
+
e(j,1) = U(2,$);
end
endfunction