Matrix form
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have a question about make a matrix which has form of
Let say I have
cel = spdiags(ones(N,1),1,N,N) - spdiags(ones(N,1),-1,N,N);
N is size in a sense that matrix size is N^3 by N^3, and first N by N part, and then N^2 by N^2 part and then N^3 by N^3 matrices super-diagonals are 1 and -1, main diagonal is 0. I hope it makes sense!
So NxN zero main diag, and from N+1,N+1 starts again same matrix till N^2xN^2, then from N^2+1,N^2+1 starts again same matrix till N^3xN^3
I have tried with kron function, which is obvious function to use, i.e.
full(kron(speye(N),cel))
but unable to create very same matrix
Let say I have this scheme in 3D, boundary conditions are zero on the boundary
(u_i,j,k+1 - u_i,j,k-1)/(2*h) => which gives my matrix A
and I have vector u = [u_111,u_112,u_121,u_122,u_211,u_212,u_221,u_222] then I have Au = b where b is any vector size of 8...
Thanks in advance!
0 Commenti
Risposte (1)
Andrei Bobrov
il 8 Dic 2011
s = N.^(1:3);
bs = arrayfun(@(x)spdiags(ones(x,1)*[-1 1],[-1 1],x,x),s,'un',0);
out = blkdiag(bs{:});
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!