How can i split a large integer into fix size groups?

1 view (last 30 days)
I have a large integer/hexadecimal value:
2329363532333233313131363536353635254B53484744534A4844534A4B4A4B4A4B6146484A484A765E383838382A2A2A2A2F313432333600
I want to split it into groups of 47 each..the last group may contain less than 47 digits. eg. output
group1:2329363532333233313131363536353635254B534847445
group2:34A4844534A4B4A4B4A4B6146484A484A765E383838382
and so on.

Accepted Answer

Stephen23
Stephen23 on 27 Feb 2018
Edited: Stephen23 on 27 Feb 2018
>> S = '2329363532333233313131363536353635254B53484744534A4844534A4B4A4B4A4B6146484A484A765E383838382A2A2A2A2F313432333600';
>> M = 47;
>> N = numel(S)-1;
>> V = [M*ones(1,floor(N/M)),1+mod(N,M)];
>> C = mat2cell(S,1,V);
>> C{1}
ans = 2329363532333233313131363536353635254B534847445
>> C{2}
ans = 34A4844534A4B4A4B4A4B6146484A484A765E383838382A
>> C{3}
ans = 2A2A2A2F313432333600

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!