필터 지우기
필터 지우기

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 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