Create a Matrix with a specific main diagonal
13 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
その他の回答 (3 件)
dpb
2015 年 11 月 30 日
Multiple ways possible; one--
>> N=5; % diagonal value
>> sz=3; % size
>> m=ones(sz)+diag(repmat(N-1,1,sz))
m =
5 1 1
1 5 1
1 1 5
>>
doc diag % for details on optional arguments for different resulting types
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!