Need help with Jacobi iteration

조회 수: 4 (최근 30일)
Osame Amayo
Osame Amayo 2017년 11월 29일
댓글: Osame Amayo 2017년 12월 6일
Currently attempting to write a jacobi iteration that will give me the same results as A\b. I am fairly new to matlab I am getting close but a few numbers are off. Is there anything that I am doing wrong? Also my professor said I don't need D but without D I can not get D_inv what am I suppose to do?
d=diag(A);
D=diag(d);
D_inv=inv(D);
E=A-D;
x=rand(n,1);
T=-D_inv*E;
C=D_inv*b;
j-1:N
x=T*x+C;
disp(x);
  댓글 수: 4
Elizabeth Reese
Elizabeth Reese 2017년 12월 6일
You do not need to form the full D or D_inv. They are both just diagonal matrices. Think about how multiplying by a diagonal matrix changes the original matrix or vector. If you leave everything in terms of d, then you can get matrix-vector multiplication instead of matrix-matrix multiplication.
Osame Amayo
Osame Amayo 2017년 12월 6일
I'm sorry I am a little confused leaving everything in terms of d. If I leave everything in terms of d, how would I complete the function?

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by