Effacer les filtres
Effacer les filtres

repeat an element in a vector

2 vues (au cours des 30 derniers jours)
Sehoon Chang
Sehoon Chang le 27 Mar 2020
Modifié(e) : Birdman le 27 Mar 2020
Hi all,
I have one vector and i wish to repeat the first element of the vector once at the very beginning.
For example:
n = [1 2 3 4 5 6 7 8 9]
to
n = [1 1 2 3 4 5 6 7 8 9]
Thank you all.
  1 commentaire
Sriram Tadavarty
Sriram Tadavarty le 27 Mar 2020
how about using
n = [n(1) n];

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 27 Mar 2020
Modifié(e) : Birdman le 27 Mar 2020
[n(1) n]
or
[repmat(n(1),1) n]

Plus de réponses (0)

Catégories

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