Large Matrices for solving linear systems

Can someone help me, I need to create the pentagonal matrix associated with the Laplace equation.. So -4 along the diagonal and 4 diagonals with 1’s. I want to be able to change the size, initially I was wanting N=33, hence 1024 x 1024.
Also an array with different values, I know I can do b=(ones(N-1)*(N-1),1) with ones or zeros, but is there a way to create a large array with different values.
I have codes for all my methods of solving linear systems, just cant create a matrix A

댓글 수: 1

Torsten
Torsten 2018년 12월 3일
You should think about whether it is necessary to form the matrix explicitly. If N gets larger, this may cause problems with available workspace.

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

 채택된 답변

추가 답변 (3개)

KSSV
KSSV 2018년 12월 3일

0 개 추천

N = 10 ;
A = diag(ones(N-2,1),-2)+diag(ones(N-1,1),-1)+4*diag(ones(N,1))+........
diag(ones(N-1,1),1)+diag(ones(N-2,1),2) ;

댓글 수: 1

JJ
JJ 2018년 12월 3일
thanks thins is similar to what I want but I need the specific pentagonal matrix associated with the discrete Laplace equation

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

Walter Roberson
Walter Roberson 2018년 12월 3일

0 개 추천

spdiags() to create the A matrix .
There is no special way to create large dense matrices.
Matt J
Matt J 2018년 12월 3일
편집: Matt J 2018년 12월 3일

0 개 추천

values=[-4,1,1,1,1];
A=toeplitz([values(:), zeros(N-numel(values),1) ]);

카테고리

도움말 센터File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

질문:

JJ
2018년 12월 3일

답변:

2018년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by