1
$\begingroup$

As part of a project I need to use autocorrelation method of estimating model paramters of an autoregressive process on MATLAB.

Can anyone tell me the simplest way to generate an AR(2) process on MATLAB so that I can estimate its model parameters $\hat{a}_{p}(k)$ and $\hat{b}_{0}$?

The difference equation for the process is given below:

$$x(n) = -0.9x(n-1) + w(n)$$

$\endgroup$
  • $\begingroup$ Hi Max! It's better if you close your previous question before asking a new one. I believe I have answered it but you place absolutely no response after getting your answer. Thank you for your understanding. $\endgroup$ – Fat32 Nov 6 '18 at 9:41
  • 1
    $\begingroup$ I owe you an apology for not going back and checking for the edit you made. Thanks for reminding! I'll keep that in mind next time. $\endgroup$ – MaxFrost Nov 6 '18 at 11:33
  • $\begingroup$ Ok. Not a big deal, but a proper way to use this site... $\endgroup$ – Fat32 Nov 6 '18 at 18:01
2
$\begingroup$

The simplest way to approximate an AR-2 process in Matlab / Octave is the following:

N = 1024;                    % number of process samples.
a = [1, -0.9, 0.2];          % denominator coefficients, p = 2.
b = [1.0];                   % numerator coefficient.
x = filter(b,a, randn(1,N)); % generate N sample of AR-2 x[n].

Note: an AR process requires a true-white noise sequence $v[n]$ at the input of the filter but here we input a single instance of a crude approximation of it. Hence the process is not truly an AR-2 but an approximation...

|improve this answer|||||
$\endgroup$
  • $\begingroup$ So if I replace randn with awgn, I might get a truer white noise. I suppose that should be fine? $\endgroup$ – MaxFrost Nov 6 '18 at 18:45
  • 1
    $\begingroup$ No they use the same function randn to generate the noise. $\endgroup$ – Fat32 Nov 6 '18 at 19:10
  • $\begingroup$ Ok one more doubt, how is the third element of a = [1 -0.9 0.2] chosen? Can we decide the value randomly or is it unique? $\endgroup$ – MaxFrost Nov 8 '18 at 7:11
  • 1
    $\begingroup$ @MaxFrost that was just a random example Ar-2 system. In you application you should determine a0, a1 and a2. a0 = 1 by definition, so AR-2 process needs two coefficients a1 and a2 to be given or determined. For the difference equation $$y[n] + \alpha y[n-1] = x[n]$$ $a_1=-\alpha $ and $a_2 = 0$ ;i.e. that's an AR-1 system indeed. $\endgroup$ – Fat32 Nov 8 '18 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.