How to set the diagonal of a cell array of matrices?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Kagalwala
am 29 Okt. 2019
Kommentiert: Mohammed Kagalwala
am 29 Okt. 2019
Hi,
I'm looking to set the diagonal of my cell array to identity, specifically eye(3,3). I know a simple for loop solution exists, but if there's something more elegant please let me know.
Thank you.
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 29 Okt. 2019
Well found, Mohammed! You should put as an answer here :-)
Here is another method
A = cell(4,4) % a cell array
n = size(A,1)
A(1:(n+1):end) = {eye(3,3)}
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!