# Problem with Autoregressive AR(3) Model. Take a look please

조회 수: 6 (최근 30일)
Miroslav 2014년 6월 8일
댓글: MAT-Magic 2019년 7월 17일
I need to plot an AR(3) process, with the following constraints.
I`m typing this
z=randn(1,1020);
z(1)=0;
phi = [-0.3, 0.9, -0.15];
x(1)=0;
for t=3:1023
x(t) = phi(1)*x(t-1) + phi(2)*x(t-2) + phi(3)*(t-3)+z(t);
end
plot(x); % code

댓글을 달려면 로그인하십시오.

### 채택된 답변

Mark Whirdy 2014년 6월 8일
x is of size 1 so need to "declare" it first as zeros(1,1023); also it is trying to access z(1023) but z has only 1020 elements
z=randn(1,1021);
x= zeros(1,1023);
z(1)=0;
phi = [-0.3, 0.9, -0.15];
x(1)=0;
for t=3:1023
x(t) = phi(1)*x(t-1) + phi(2)*x(t-2) + phi(3)*(t-3)+z(t-2);
end
plot(x); % code
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
MAT-Magic 2019년 7월 17일
Inside the for loop, I think the x is missing, it should be like phi(3)*x(t-3). Isn't it?

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Conditional Mean Models에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by