Filling cells with repetitive strings
조회 수: 39 (최근 30일)
이전 댓글 표시
Hi
I want to create a 1x60 cell array (60 different elements). The elements 1:10 each should contain a certain string, say 'hello', then 11:20 should contain say 'tree' etc. How do I do this effectively? Currently I am using different loops for each string, but that seems not to be very effective..thanks
댓글 수: 0
답변 (3개)
Walter Roberson
2017년 1월 24일
https://www.mathworks.com/help/matlab/ref/repelem.html
Works on cells too.
Jan
2017년 1월 24일
Strings = {'hello', 'tree', 'third', 'fifth', 'sixth'};
C = reshape(repmat(Strings, 10, 1), 1, []);
댓글 수: 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!