Enter same string in an array.

36 vues (au cours des 30 derniers jours)
Akashdeep Kaur
Akashdeep Kaur le 16 Juil 2022
Commenté : Akashdeep Kaur le 16 Juil 2022
hello, I would like to enter same string in an array. like:
Array1=[a,a,a,a,a,a]
Thanks.

Réponse acceptée

Harshit Gupta
Harshit Gupta le 16 Juil 2022
Hi, if your question is just about how to create an array of string, you can do it like this:
Array1 = ["a", "a", "a", "a", "a"]
Array1 = 1×5 string array
"a" "a" "a" "a" "a"
Now if you want to repeat a single string multiple times to create an array, do it like this:
str = "a";
Array1 = repmat(str, 1, 5)
Array1 = 1×5 string array
"a" "a" "a" "a" "a"
Refer to the documentation to know more: repmat
Hope this helps!
  1 commentaire
Akashdeep Kaur
Akashdeep Kaur le 16 Juil 2022
Thank you for helping.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by