How to repeat indivisual element of a matrix?

1 回表示 (過去 30 日間)
Saiem Solimullah
Saiem Solimullah 2018 年 3 月 17 日
コメント済み: Saiem Solimullah 2018 年 3 月 21 日
Suppose, i have a matrix a=[1 0 1 1 0 0 1 1] and i want to repeat every element of this matrix by 3 times using for loop . as the new matrix will be b=[1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1] . How easily can solve??

採用された回答

Rene Riha
Rene Riha 2018 年 3 月 17 日
for i=1:length(a)
b(3*i-2:3*i)=a(i);
end
  2 件のコメント
Saiem Solimullah
Saiem Solimullah 2018 年 3 月 19 日
Thank you... this is helpful..
Saiem Solimullah
Saiem Solimullah 2018 年 3 月 21 日
mam, can u help me with the rebuilt of vector a using for loop please?

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 3 月 17 日
Use the repelem function introduced in release R2015a.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ


Translated by