ループを使わず長さの違う1つの配列の作成方法を教えてください
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    翔 池田
 am 22 Apr. 2021
  
    
    
    
    
    Kommentiert: Hernia Baby
      
 am 22 Apr. 2021
            例として以下のような配列を作成したいです.
a=[2;3]; %個数
b=[1;78]; %[グラム]
という条件で
c=[1;1;78;78;78];
という形を作りたいです.
これをループなしで出したいのですが,どうすればよろしいでしょうか    
0 Kommentare
Akzeptierte Antwort
  Hernia Baby
      
 am 22 Apr. 2021
        repelem関数で要素を増やすことができます
a = [2;3];
b = [1;78];
c = repelem(b,a)
c =
     1
     1
    78
    78
    78
------------------------
詳しくはこちらどうぞ
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
				Mehr zu ループと条件付きステートメント finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
