Cell indexing and redefing

3 ビュー (過去 30 日間)
Mitchell
Mitchell 2012 年 3 月 6 日
Hello,
So I have trying to redefine a cell so I can manipulate it easilier.
I am utilizing regexp to separte a long, +3000 elements of items like '30 to 50'.
So on a shorter example I am doing AA =
'85 to 92 °C'
'85 to 92 °C'
'55 to 64 °C'
'55 to 64 °C'
>> test1 = regexp(AA,'\d\w*','match')
test1 =
{1x2 cell}
{1x2 cell}
{1x2 cell}
{1x2 cell}
but now I want create two cells, or atleast one cell with two columns that looks like this on completion.
test2(:,:) =
'85' '92'
'85' '92'
'55' '64'
'55' '64'
Currently I am doing this in a for loop, but I was wondering/hoping that there is a vectorized way to complete this task?
for n=1:2; for m=1:length(test1); test(m,n)= mi{m}(n); end; end
Cheers and many thanks,
Mitchell

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 3 月 6 日
AA =cellstr(['85 to 92 °C'
'85 to 92 °C'
'55 to 64 °C'
'55 to 64 °C']);
BB = regexp(AA,'\d\w*','match');
CC = vertcat(BB{:})
  1 件のコメント
Mitchell
Mitchell 2012 年 3 月 7 日
vertcat is what I was missing, thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by