Separating a column in two others when there are empty cells

Guys,
I have the following cell Column
' '
'4W231108'
'4W211208'
'4W180109'
'4W150209'
'4W150309'
'4W120409'
AS you can see the first element of the above column is empty
and I want to obtain Column 1 column 2
“ ” ““
'4W 231108'
'4W 211208'
'4W 180109'
'4W 150209'
'4W 150309'
'4W 120409'
Any suggestions?
thanks

 採用された回答

Sean de Wolski
Sean de Wolski 2012 年 6 月 21 日

0 投票

How about this hideous idea?
C = {''; '4W231108' ; '4W211208' ; '4W180109' ; '4W150209' ; '4W150309' ; '4W120409'}
C2 = cellfun(@(x)[{x(1:min(numel(x),2))} {x(3:end)}],C,'uni',false);
C2 = vertcat(C2{:});

8 件のコメント

antonet
antonet 2012 年 6 月 21 日
Excellent!
antonet
antonet 2012 年 6 月 21 日
I forgot to tell you that I wanted to have
'4W 23/11/08'
'4W 21/12/08'
'4W 18/01/09'
'4W 15/02/09'
'4W 15/03/09'
'4W 12/04/09'
Sean de Wolski
Sean de Wolski 2012 年 6 月 21 日
then just add a space instead of two cells
[x(1:min(numel(x),2)) ' ' x(3:end)],
antonet
antonet 2012 年 6 月 21 日
I tried but it does not work
antonet
antonet 2012 年 6 月 21 日
C2 = cellfun(@(x)[x(1:min(numel(x),2)) ' ' x(3:end)], C,'uni',false);
C2 = vertcat(C2{:});
antonet
antonet 2012 年 6 月 21 日
I still get 231108 211208 and so forth....
Sean de Wolski
Sean de Wolski 2012 年 6 月 21 日
Well did you copy C in ?
antonet
antonet 2012 年 6 月 21 日
what do you mean?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by