Effacer les filtres
Effacer les filtres

how to duplicate rows in a 2D matrix

1 vue (au cours des 30 derniers jours)
Naufal Arfani
Naufal Arfani le 7 Jan 2021
Réponse apportée : KSSV le 7 Jan 2021
hello everyone, for example I have an array like the one below, I want to duplicate the array value on row 2nd to the value on row 1st does anyone know the easy way? I have tried the code below but it still has an error, thank you
A = magic(4);
A(2,:) = [1,:];
end

Réponse acceptée

KSSV
KSSV le 7 Jan 2021
A = magic(4);
A(2,:) = A(1,:)
A = 4×4
16 2 3 13 16 2 3 13 9 7 6 12 4 14 15 1

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by