expanding the existing matrix

1 vue (au cours des 30 derniers jours)
mahesh chathuranga
mahesh chathuranga le 12 Sep 2013
I have a matrix like this.
M=[1 2 3;
4 5 6].
I want to expanding it into
M'=[1 1 2 2 3 3;
1 1 2 2 3 3;
1 1 2 2 3 3;
4 4 5 5 6 6;
4 4 5 5 6 6;
4 4 5 5 6 6].
I try to do this.but stil i could not get correct result?

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 12 Sep 2013
Modifié(e) : Andrei Bobrov le 12 Sep 2013
kron(M,ones(3,2))
or
m = 3;
n= 2;
s = size(M);
out = reshape(permute(reshape(repmat(M,m,n),s(1),m,s(2),n),[2 1 4 3]),m*s(1),[]);
  1 commentaire
mahesh chathuranga
mahesh chathuranga le 12 Sep 2013
thak you very much

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 12 Sep 2013
Instead of expanding it (resulting in more memory consumption) consider using this instead

Catégories

En savoir plus sur Numeric Types 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