フィルターのクリア

How to divide a sequence into 8 groups?

4 ビュー (過去 30 日間)
Reinhardt RADING
Reinhardt RADING 2022 年 1 月 22 日
回答済み: DGM 2022 年 1 月 22 日
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.

採用された回答

DGM
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
v = '1134066498316424744666518936461452422195836459588198717282983265'
% to get a reshaped character array
vreshaped = reshape(v,8,[]).'
vreshaped = 8×8 char array
'11340664' '98316424' '74466651' '89364614' '52422195' '83645958' '81987172' '82983265'
% to get as a numeric array instead
vnum = str2num(vreshaped)
vnum = 8×1
11340664 98316424 74466651 89364614 52422195 83645958 81987172 82983265
% or
vnum = str2double(num2cell(vreshaped,2))
vnum = 8×1
11340664 98316424 74466651 89364614 52422195 83645958 81987172 82983265
% or
vnum = str2double(mat2cell(v,1,ones(1,numel(v)/8)*8)).'
vnum = 8×1
11340664 98316424 74466651 89364614 52422195 83645958 81987172 82983265

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by