フィルターのクリア

How to create a vector with the same string elements?

98 ビュー (過去 30 日間)
osminbas
osminbas 2012 年 4 月 19 日
編集済み: Marco Gomez 2023 年 7 月 6 日
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]);
?
  2 件のコメント
Diego Franco
Diego Franco 2021 年 3 月 30 日
but this creates a cell for every letter you put in that string
Marco Gomez
Marco Gomez 2023 年 7 月 6 日
編集済み: Marco Gomez 2023 年 7 月 6 日
try
repmat("hi",[1 5])';

サインインしてコメントする。

その他の回答 (1 件)

Luiz Guilherme Pancini
Luiz Guilherme Pancini 2022 年 1 月 27 日
"hi" + strings(10,1)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by