Cell indexing and redefing

3 次查看(过去 30 天)
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{:})

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by