for k=n-1:1
x(n)=cnew(n)/dnew(n)
x(k)=(cnew(k)-a(k)*x(k+1))/d(k)
end
Tnew(i,j)=x(i)
P.S. cnew and all others are known.
Still while running this i am getting an error-
Unrecognized function or variable 'x'.
Error in ADI (line 51)
Tnew(i,j)=x(i)

 채택된 답변

Cris LaPierre
Cris LaPierre 2020년 9월 25일
편집: Cris LaPierre 2020년 9월 26일

0 개 추천

What is the value of n?
The most obvious thing to me is that your for loop doesn't actually run, so x is never created.
The loops don't run because you start at k=n-1 and ends when k=1. You're not getting an error that your index has to be positive, so n>=2. If x is not created at all, that means n>=3, causing to loop indices to be 2:1, resulting in an empty array, which means your loop never runs.

댓글 수: 1

ravi shukla
ravi shukla 2020년 9월 26일
i think to add step -1.
for k=n-1:-1:1
this will resolve my issue..say n=5
so k=4:-1:1
4
3
2
1

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 9월 25일

편집:

2020년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by