Filter löschen
Filter löschen

How to repeat indivisual element of a matrix?

3 Ansichten (letzte 30 Tage)
Saiem Solimullah
Saiem Solimullah am 17 Mär. 2018
Kommentiert: Saiem Solimullah am 21 Mär. 2018
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??

Akzeptierte Antwort

Rene Riha
Rene Riha am 17 Mär. 2018
for i=1:length(a)
b(3*i-2:3*i)=a(i);
end
  2 Kommentare
Saiem Solimullah
Saiem Solimullah am 19 Mär. 2018
Thank you... this is helpful..
Saiem Solimullah
Saiem Solimullah am 21 Mär. 2018
mam, can u help me with the rebuilt of vector a using for loop please?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Steven Lord
Steven Lord am 17 Mär. 2018
Use the repelem function introduced in release R2015a.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by