How to create a vector with the same string elements?

96 次查看(过去 30 天)
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!

采纳的回答

Sean de Wolski
Sean de Wolski 2012-4-19
repmat('hi',[1 5]);
?

更多回答(1 个)

Luiz Guilherme Pancini
"hi" + strings(10,1)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by