repmat usage for cellarray
조회 수: 112 (최근 30일)
이전 댓글 표시
data = 32 x 1
double_array=[repmat(data,1,286);]; %= 286 x 32 double
Now, I need to replace data with data_string as follows:
data_string = 32 x 3 char aray
Then, I need to create cell array using the above repmat operation. I tried the below but it gave error:
cell_array=repmat({data_string,1,286});
What is the proper way to construct cell_array matrix? My matlab version is 2019a.
댓글 수: 0
채택된 답변
Jan
2021년 11월 18일
If this is what you want:
cell_array = PG01 PG02 PG03 . . . PG32
PG01 PG02 PG03 . . . PG32
. . . . . . PG32
use:
cell_array = repmat(sprintf('PG%02d', 1:32), 286, 1)
In your call:
cell_array=repmat({data_string,1,286});
you provide a cell as input of repmat. But then the number of repetitions are missing. Mayby you mean:
cell_array=repmat(data_string, 1, 286);
댓글 수: 0
추가 답변 (1개)
Chunru
2021년 11월 18일
data_string = reshape(char(32:127), 3, []) % some characters32 x 3 char aray
cell_array=repmat({data_string},1,3)
cell_array{3}
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!