Cell indexing and redefing

3 views (last 30 days)
Mitchell
Mitchell on 6 Mar 2012
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

Accepted Answer

Sean de Wolski
Sean de Wolski on 6 Mar 2012
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 Comment
Mitchell
Mitchell on 7 Mar 2012
vertcat is what I was missing, thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!