ループを使わず長さの​違う1つの配列の作成​方法を教えてください

6 visualizaciones (últimos 30 días)
翔 池田
翔 池田 el 22 de Abr. de 2021
Comentada: Hernia Baby el 22 de Abr. de 2021
例として以下のような配列を作成したいです.
a=[2;3]; %個数
b=[1;78]; %[グラム]
という条件で
c=[1;1;78;78;78];
という形を作りたいです.
これをループなしで出したいのですが,どうすればよろしいでしょうか

Respuesta aceptada

Hernia Baby
Hernia Baby el 22 de Abr. de 2021
repelem関数で要素を増やすことができます
a = [2;3];
b = [1;78];
c = repelem(b,a)
c =
1
1
78
78
78
------------------------
詳しくはこちらどうぞ

Más respuestas (1)

翔 池田
翔 池田 el 22 de Abr. de 2021
早急のご連絡ありがとうございます.
非常に助かりました.
  1 comentario
Hernia Baby
Hernia Baby el 22 de Abr. de 2021
解決してなによりです。
私の回答を採用していただけると、
本件クローズできるのでよろしければお願いいたします。

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!