How to repeat indivisual element of a matrix?

3 次查看(过去 30 天)
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

更多回答(1 个)

Steven Lord
Steven Lord 2018-3-17
Use the repelem function introduced in release R2015a.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by