任意サイズの単位ベクトルの作り方

31 views (last 30 days)
Masato Hayashi
Masato Hayashi on 29 Dec 2018
Commented: Kojiro Saito on 11 Jan 2019
任意サイズの単位ベクトルの作り方を教えてください。
a=[1,1,1,1,1,…]
簡単に作れる方法を知りたいです。

Answers (1)

Kojiro Saito
Kojiro Saito on 29 Dec 2018
onesを使う方法が最も簡単だと思います。1行n列の単位ベクトルを作成したい時、ones(1, n)で作成できます。
例えばnが20の時はこんな感じです。
n = 20;
a = ones(1, n);
  2 Comments
Masato Hayashi
Masato Hayashi on 11 Jan 2019
できました。ありがとうございました!
Kojiro Saito
Kojiro Saito on 11 Jan 2019
解決できてよかったです。差し支えなければ、回答の採用(accept)もポチッとお願いできますでしょうか。

Sign in to comment.

Categories

Find more on 行列および配列 in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!