concatenating array using cellstr and repmat
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi All,
I have the following code
str = cellstr(char('This','Orthis'));
x = round(rand(10,1))+1;
output = [repmat('some text ',10,1) str{x}]
I want the output to look like:
output =
some text OrThis
some text This
some text This
etc..
where the last word in each row is selected by str{x}. This is not working, as the str{x} part of the concatenation is not generating the appropriate array. Any suggestions? Thanks!
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 5월 2일
str = cellstr(char('This','Orthis'))
x = round(rand(10,1))+1
output = [repmat('some text ',10,1) char(str(x))]
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!