Comining the values and merging
22 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Andrei Bobrov
on 8 Aug 2012
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{:}];
0 Comments
More Answers (1)
Oleg Komarov
on 8 Aug 2012
B = num2cell(A,1);
B = [B{:,1} strcat(B{2:5}) strcat(B{3:6}) strcat(B{4:7}) strcat(B{5:8})];
0 Comments
See Also
Categories
Find more on Clocks and Timers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!