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 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