Given a linear system i want to do Gauss-Seidel iteration.But getting error.Would appreciate if anyone fix me the code. Thanks.

조회 수: 1 (최근 30일)
>> x(1)=1.5;
>> y(1)=-1;
>> z(1)=1;
>> iter(1)=0;
>> for n=1:4
iter(n+1)=n;
x(n+1)=(16+3*y(n)-2*z(n))/8;
y(n+1)=(-9+2*x(n+1)-z(n))/8;
z(n+1)=(1+2*x(n+1)-4*y(n+1))/10;
end
>> Solution = [iter',x',y',z’]

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 5월 30일
No coding syntax error
x(1)=1.5;
y(1)=-1;
z(1)=1;
iter(1)=0;
for n=1:4
iter(n+1)=n;
x(n+1)=(16+3*y(n)-2*z(n))/8;
y(n+1)=(-9+2*x(n+1)-z(n))/8;
z(n+1)=(1+2*x(n+1)-4*y(n+1))/10;
end
Solution = [iter',x',y',z']
Result:
Solution =
0 1.5 -1 1
1 1.375 -0.90625 0.7375
2 1.4758 -0.84824 0.73445
3 1.4983 -0.84223 0.73655
4 1.5 -0.84206 0.73683
  댓글 수: 3
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 5월 30일
편집: KALYAN ACHARJYA 2021년 5월 30일
Can you delete the z' (transpose sign) & type it again?
Note on the z' (superscript sign)

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

카테고리

Help CenterFile Exchange에서 Systems Of Linear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by