Effacer les filtres
Effacer les filtres

How to shuffle an array?

3 vues (au cours des 30 derniers jours)
faa nad
faa nad le 4 Juin 2013
Hi ,
I want to concatenate two arrays by shuffling in the following format.I used randperm it keeps on changing the array position.i need to maintain a static position for it.
a=[1 2 3 4 5]; b=[10 20 30 40 50]; if 'a' and 'b are two individual arrays say,then the concatenated array must be as follows
c=[1 10 2 20 3 30 4 40 5 50]

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 4 Juin 2013
Modifié(e) : Andrei Bobrov le 4 Juin 2013
reshape([a;b],1,[]);
or
out = zeros(1,numel(a)*2);
out(1:2:end) = a;
out(2:2:end) = b;
  1 commentaire
faa nad
faa nad le 4 Juin 2013
thank u sir,

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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