Cell indexing and redefing

3 Ansichten (letzte 30 Tage)
Mitchell
Mitchell am 6 Mär. 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

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 6 Mär. 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 Kommentar
Mitchell
Mitchell am 7 Mär. 2012
vertcat is what I was missing, thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by