Create diagonals along a block matrix
Afficher commentaires plus anciens
Good Morning,
I have a 4x4 matrix containing values only in the first column and all 0's in the remaining spaces. The values contained in each cell are actually vectors of multiple values.
I'd like to make the first value (vector) of the first row be carried over to the second row of the second column, the third row of the third column, and so on. I would like to do the same for the second value (vector) of the first row, which should be reported in the third row of the second column, and so on, in order to create diagonals along the matrix containing the same values.
How can I do this?
Thank you so much!!
4 commentaires
Jan
le 15 Déc 2021
"I have a 4x4 matrix containing values only in the first column and all 0's in the remaining spaces"
X = [rand(4, 1), zeros(4, 3)];
"The values contained in each cell are actually vectors of multiple values"
Here is no cell. Which values do you mean? What is a vector of multiple values?
"I would like to do the same for the second value (vector) of the first row"
The 2nd value of the first row is 0. What does carrying over mean?
Currently the description as text is not useful enough. Please edit the question and insert some code, which clarifies what the inputs are and what you want as output.
sc
le 15 Déc 2021
Sorry, this is a Matlab forum. This is not a Matlab matrix:
A =
[0,0]
[1,1]
[2,1]
[3,3]
Please use Matlab syntax, because this is the common convention here. Thanks.
A matrix has 2 diagonals only. I assume you mean the sub- and super-diagonals?
"B=blkdiag(A{:})" - Now A is a cell array? Sorry for beeing nitpicking, but the more the readers have to guess, the more unlikely is a useful answer.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Operating on Diagonal Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!