Comining the values and merging

20 ビュー (過去 30 日間)
kash
kash 2012 年 8 月 8 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 8 月 8 日
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{:}];

その他の回答 (1 件)

Oleg Komarov
Oleg Komarov 2012 年 8 月 8 日
B = num2cell(A,1);
B = [B{:,1} strcat(B{2:5}) strcat(B{3:6}) strcat(B{4:7}) strcat(B{5:8})];

カテゴリ

Help Center および File ExchangeClocks and Timers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by