Attempted to access delta(-2); index must be a positive integer or logical. Error in ==> ANC at 20 h(n)=delta(n-3)-2.7083*delta(n-4)+4.1861*delta(n-5)-3.0451*delta(n-6)+0.73071*delta(n-7);
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear all,
I got this error. please help me. thank you.
Attempted to access delta(-2); index must be a positive integer or logical.
Error in ==> ANC at 20
h(n)=delta(n-3)-2.7083*delta(n-4)+4.1861*delta(n-5)-3.0451*delta(n-6)+0.73071*delta(n-7);
댓글 수: 0
채택된 답변
Walter Roberson
2016년 1월 25일
편집: Walter Roberson
2016년 1월 25일
When n is 1, n-3 is -2
You loop over n is going to have trouble unless you start at n = 8
What you initialize h(1) through h(7) to is a good question.
By the way, consider conv() with fliplr([0, 0, 1, -2.7083, +4.1861, -3.0451, +0.73071])
댓글 수: 2
Walter Roberson
2016년 1월 25일
for n=1:N at the end should be replaced with for n=8:N
By the way, after your "for n=1:N", n is going to be left at its last value, N, so in the next line, n==0 is going to be false so no values in delta will be initialized. You do not otherwise initialize delta so your delta is going to be an empty array, which is a problem. You need your delta array to be at least N long.
Your code does not use x after you calculate it.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!