I did it in other way. I defined Amdb (A main diag. boundary blocks) in your code and then applied this:
It works and now I will try to go further with the solution of the examined problem. Thank you and regards!
Thank you for the quick and complete answer. Unfortunately, I'm not familiar with a "repmat" and how to replicate only the middle blocks and replace the first and the last one.
I tried this:
v = repmat(AmdF(1),n,1);
v = repmat(Amd(:),n,1);
v = repmat(AmdL(n),n,1);
but of course it doesn't work....
Have you got a clue how to call it?
Thank you in advance and appreciation again for the code!!!
can please help me to find out if it's possible, using "blktridiag", to generate a block tridiagonal matrix A, whose main diagonal (Amd) to starts and ends with different copies of Amd. I.e. AmdFirst and AmdLast~= Amd...
[AmdF Asup 0 0 0;
Asub Amd Asup 0 0;
0 Asub Amd Asup 0;
0 0 Asub Amd Asup;
0 0 0 Asub AmdL]
I hope that the explanation was clear enought! Thank you in advance!
Hello, can you help with this error:??? Undefined function or method 'blktridiag' for input arguments of type
Probably, it is a stupid question, but I really need help! Thank you in advance!
Sorry. It was not written to accept a cell array of sparse matrices. It does work if you pass in a single element that is intended to be replicated down the diagonals. So this works of course:
A = sparse([1 0;0 4]);
bigA = blktridiag(A,A,A',10);
And blktridiag would work if MATLAB supported 3-d sparse arrays.
blkdiag works for you because you can pass in a comma separated list of elements. So an easy fix is for you to use blkdiag to build the main diagonal. Then use blkdiag to build the sub and super diagonal arrays. Shift them over as necessary by padding with zeros, and then just add the three arrays together. No problem.
Hi, would it be possible to use blktridiag with cell arrays of sparse matrices? I have a 3d volume (nxmxp) and I must create a tridiagonal matrice of size (nxmxp)x(nxmxp) where the matrices (nxm)x(nxm) for all the slices p of the volume are on the main diagonal. The sub and sup diagonals are matrices also of size (nxm)x(nxm) representing the relationship between neighboring slices.
W11 W12 [ ] [ ]
W21 W22 W23 [ ]
[ ] W32 W33 W34
[ ] [ ] W43 W44
Where W21 is the same as W12' (transpose).
Since Matlab doesn't support 3d sparse matrices, I thought I could use a cell array. The function blkdiag from Matlab works with my cell array, but I am missing the sub and sup diagonals.