How to set the diagonal of a cell array of matrices?
8 ビュー (過去 30 日間)
古いコメントを表示
Mohammed Kagalwala
2019 年 10 月 29 日
コメント済み: Mohammed Kagalwala
2019 年 10 月 29 日
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 件のコメント
採用された回答
Jos (10584)
2019 年 10 月 29 日
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)}
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!