How to divide a sequence into 8 groups?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi there!
I have a sequence of data i.e 1123412355689114567807698......................27345678 (until the 4096th value)
I would like to divide them in groups of 8. For example:
11234123
55689114
56780769
.
.
.
27345678
Is there a way i can do this?
Thank you in advance.
댓글 수: 0
채택된 답변
DGM
2022년 1월 22일
I am going to assume that your "data" is a long character vector with no delimiters.
v = char(randi([48 57],1,64)) % example vector
% to get a reshaped character array
vreshaped = reshape(v,8,[]).'
% to get as a numeric array instead
vnum = str2num(vreshaped)
% or
vnum = str2double(num2cell(vreshaped,2))
% or
vnum = str2double(mat2cell(v,1,ones(1,numel(v)/8)*8)).'
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!