You could use mat2cell to split the string into strings in a cell array (note that I added 3 to the start of A, so that it reads the DAT part separately): >> str = 'DAT00000706LR0106700000100000002+000000194018602202101-0002-00010+000+0000000000+000+000+071+072008009000600000000000+00000+206+2060230000000000402+0000+000+001';
>> A = [3,4,2,2,1,1,5,6,4,4];
>> C = mat2cell(str(1:sum(A)),1,A);
>> C{:}
ans = DAT
ans = 0000
ans = 07
ans = 06
ans = L
ans = R
ans = 01067
ans = 000001
ans = 0000
ans = 0002
Best Answer