Borrar filtros
Borrar filtros

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

24 visualizaciones (últimos 30 días)
Masato Hayashi
Masato Hayashi el 29 de Dic. de 2018
Comentada: Kojiro Saito el 11 de En. de 2019
任意サイズの単位ベクトルの作り方を教えてください。
a=[1,1,1,1,1,…]
簡単に作れる方法を知りたいです。

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre 行列および配列 en Help Center y File Exchange.

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!