Comining the values and merging
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 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 Kommentare
Weitere Antworten (1)
Oleg Komarov
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Clocks and Timers finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!