Matrix with some sort of pattern
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everybody, i would like to make a matrices like this [1,1,1,1,1,0,0,0,0,0;0,0,0,0,0,1,1,1,1,1;] or this [-1 0 0;-1 0 0;-1 0 0;-1 -1 0;-1 -1 0; -1 -1 0;-1 -1 -1;-1 -1 -1;-1 -1 -1] in such a way that 'for' loop would be unnecessary.i was thinking something about repmat or so,because of the pattern that this kind of matrices seem to have.any ideas??? Thank you!!
0 件のコメント
採用された回答
Matt J
2013 年 4 月 24 日
You could use KRON
>> kron(eye(2), ones(1,5))
>> kron(tril(ones(3)),-ones(3,1))
2 件のコメント
Mishaal Amir
2022 年 11 月 17 日
How to do this for an 9 by 9 matrix, with the number 9s surrounding the borders and the 0s in the center of the matrix?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!