MATLAB: Comining the values and merging

merging

A=
'' 'c0' 'c1' 'c2' 'c3' 'c4' 'c5' 'c6'
'yar12' 'hi' 'hello' 'hi' 'hello' 'hi' 'hi' 'hi'
'yar13' hello' 'hi' 'hi' 'hello' 'hi' 'hi' 'hi'
'yar14' 'hi' 'hi' 'hi' 'hello' 'hello' 'hello' 'hi'
'yar15' 'hello' 'hi' 'hi' 'hi' 'hi' 'hi' 'hello'
'yar16' 'hello' 'hi' 'hi' 'hello' 'hello' 'hello'
'yar17' 'hi' 'hi' 'hi' 'hi' 'hi' 'hi' hello'
I need to combine intervals
c0c1c2c3
c1c2c3c4
c2c3c4c5
c3c4c5c6
so for example for yar12
'c0c1c2c3' 'c1c2c3c4' 'c2c3c4c5' 'c3c4c5c6'
'yar12' 'hihellohihello' 'hellohihellohi' 'hihellohihi' 'hellohihihi'
like this i need for all values from yar13 to yar130(for sample i have posted till yar17)
please help

Best Answer

A= {'' 'c0' 'c1' 'c2' 'c3' 'c4' 'c5' 'c6'
'yar12' 'hi' 'hello' 'hi' 'hello' 'hi' 'hi' 'hi'
'yar13' 'hello' 'hi' 'hi' 'hello' 'hi' 'hi' 'hi'
'yar14' 'hi' 'hi' 'hi' 'hello' 'hello' 'hello' 'hi'
'yar15' 'hello' 'hi' 'hi' 'hi' 'hi' 'hi' 'hello'
'yar16' 'hello' 'hi' 'hi' 'hello' 'hello' 'hello' 'hello'
'yar17' 'hi' 'hi' 'hi' 'hi' 'hi' 'hi' 'hello' };
A2 = num2cell(A,1);
idx = hankel(2:5,5:8);
out = [A2(:,1),arrayfun(@(i1)strcat(A2{idx(i1,:)}),1:size(idx,1),'un',0)];
out = [out{:}];