How can I create a matlab matrix below?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
kimjandi
am 3 Mär. 2021
Beantwortet: Walter Roberson
am 3 Mär. 2021
Hi, I've been wanting to construct a matlab matrix that is n by n. and looks like this. I've beeen trying to use diag but the function diag doesn't provide this. so m a bit confused. Please help!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 3 Mär. 2021
N = 6;
diag(-2*ones(1,N)) + diag(ones(1,N-1),-1) + diag(ones(1,N-1),1)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!