summaryrefslogtreecommitdiff
path: root/macros/armcov.sci
diff options
context:
space:
mode:
authorSunil Shetye2018-07-25 17:11:09 +0530
committerSunil Shetye2018-07-26 23:50:17 +0530
commit1251f70aa3442736ce6fd9c4fb7fbce412af5a52 (patch)
tree360311ffaf6151c5066439f481e8ac38cfd047b9 /macros/armcov.sci
parent9ca7882cee16ad48b18df989e8300c697010e55a (diff)
downloadFOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.tar.gz
FOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.tar.bz2
FOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.zip
code changes by Kartik Hegde during FOSSEE Fellowship 2018
Diffstat (limited to 'macros/armcov.sci')
-rw-r--r--macros/armcov.sci37
1 files changed, 28 insertions, 9 deletions
diff --git a/macros/armcov.sci b/macros/armcov.sci
index 0c5158c..e36b4c7 100644
--- a/macros/armcov.sci
+++ b/macros/armcov.sci
@@ -1,22 +1,41 @@
-function [ar_coeff, var_est] = armcov(data_in, order)
-
- checkNArgin(2,2, argn(2));
+//Autoregressive all-pole model parameters — modified covariance method
+//Calling Sequence-
+//a = armcov(x,p)
+//[a,e] = armcov(x,p)
+//Parameters
+//x:input signal
+//p:order
+//a:output of an AR system driven by white noise
+//e:variance estimate
+//Description
+//This function uses the modified covariance method to fit a pth-order autoregressive (AR) model to the input signal x.
+
+//Example :
+//A = [1 -2.7607 3.8106 -2.6535 0.9238];
+//y = filter(1,A,0.2*rand(1024,1,"normal"));
+//arcoeffs = armcov(y,4)
+//OUTPUT : // since "rand" function is used, output doesn't always remains same. It differs by some amount.
+// 1. - 2.7450144 3.7762385 - 2.6201362 0.9104109 0.9104109
+
+ function [ar_coeff, var_est] = armcov(data_in, order)
+
+ checkNArgin(2,2, argn(2)); // function call
method = 'modified';
[ar_coeff, var_est, msg] = arParEst(data_in, order, method);
if ~isempty(msg) then
error(msg);
end
-
-
+
+
endfunction
function checkNArgin(min_argin, max_argin, num_of_argin)
if num_of_argin < min_argin then
- error('Not enough input arguments')
+ error('Not enough input arguments') // Number of input arguments should be greater than min_argin
end
-
+
if num_of_argin > max_argin then
- error('Too many input arguments')
+ error('Too many input arguments') // Number of input arguments should be lesserr than max_argin
end
-
+
endfunction