How to create a vector with the same string elements?

Hello,
I am trying to create a vector with all the same string elements. When it is numeric, it is as easy as ones(10,1)*5, which gives a vector of "fives". How do you do the same thing with a string, say if I want a vector with all the elements of string 'hi'? Thank you!

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 19 de Abr. de 2012
repmat('hi',[1 5]);
?

2 comentarios

but this creates a cell for every letter you put in that string
Marco Gomez
Marco Gomez el 6 de Jul. de 2023
Editada: Marco Gomez el 6 de Jul. de 2023
try
repmat("hi",[1 5])';

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Abr. de 2012

Editada:

el 6 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by