Create a Matrix with a specific main diagonal
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adzlxix
am 30 Nov. 2015
Bearbeitet: Adzlxix
am 12 Dez. 2015
I want to create a matrix of all one's with the main diagonal of value n.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (3)
dpb
am 30 Nov. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!