Matlab expanding matrix quickly
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Niels de Vries
il 3 Ago 2018
Modificato: Fangjun Jiang
il 3 Ago 2018
Hey all,
Suppose you have as input: matrix A = [10 9 8] and some factor X = 3
As output i would like to obtain: R = [10 10 10 9 9 9 8 8 8]
I am wondering if there are better (faster) solutions then my solution below:
R = zeros(1,length(A)*X);
for i =1:X
R(1+length(A)*(i-1):1:length(A)*i) = A(i);
end
0 Commenti
Risposta accettata
Fangjun Jiang
il 3 Ago 2018
Modificato: Fangjun Jiang
il 3 Ago 2018
reshape(repmat(A,X,1),1,[])
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!