任意サイズの単位ベクトルの作り方
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
任意サイズの単位ベクトルの作り方を教えてください。
a=[1,1,1,1,1,…]
簡単に作れる方法を知りたいです。
0 Kommentare
Antworten (1)
Kojiro Saito
am 29 Dez. 2018
onesを使う方法が最も簡単だと思います。1行n列の単位ベクトルを作成したい時、ones(1, n)で作成できます。
例えばnが20の時はこんな感じです。
n = 20;
a = ones(1, n);
Ref: onesのドキュメント (R2015b)
2 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!