# Expanding Array as following;

1 vue (au cours des 30 derniers jours)
도연 원 le 22 Sep 2022
Commenté : 도연 원 le 24 Sep 2022
I have logical vector here;
A=[1 0 0 1];
I want to expand this array like this, this is like expanding vector A by 3 times.
B=[1 1 1 0 0 0 0 0 0 1 1 1];
I tried function 'upsample', but it doesn't work as I intended like above.
Also made this logical values into 'double' and used interp1 function, also did not work.
Also searched in the Matlab Community, think that there is 100% matching question wharrich what I am seeking of...
Thanks!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Davide Masiello le 22 Sep 2022
Modifié(e) : Davide Masiello le 22 Sep 2022
Try this
A = [1 0 0 1];
B = repelem(A,3)
B = 1×12
1 1 1 0 0 0 0 0 0 1 1 1
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
도연 원 le 24 Sep 2022
Actually I also need the case of repelem(A,5) or 10.
For the matter that I am having now, repelem makes a little bit easier.
Thanks Davide, and thanks for the Cris' too.

Connectez-vous pour commenter.

### Plus de réponses (1)

Cris LaPierre le 22 Sep 2022
A=[1 0 0 1];
B = [A;A;A];
B = B(:)'
B = 1×12
1 1 1 0 0 0 0 0 0 1 1 1
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by