Vector operations

3 vues (au cours des 30 derniers jours)
Steven
Steven le 7 Nov 2011
I'm looking for something that can repeat a vector without. For exemple, here a is repeated 4 times :
a = [1,2,5];
b = cellfun(a, 4);
b = [1 1 1 1 2 2 2 2 5 5 5 5];
thx

Réponse acceptée

Wayne King
Wayne King le 7 Nov 2011
One way:
a = [1,2,5];
b = reshape(repmat(a,4,1),12,1);
  1 commentaire
Andrei Bobrov
Andrei Bobrov le 7 Nov 2011
b = reshape(ones(4,1)*a,1,[]);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by