I have two cellArray which class are cell. I want to extract first column of these cellArray.

cellArray=
' 334 4261461.0645 2661117.6797 3918916.0472'
' 352 4266205.852 2659683.96 3914798.2885'
' 404 4258400.8221 2662966.354 3920634.872'
' 414 4255211.3943 2666063.0462 3921735.7546'
%cellArray 8x1 1824 cell
I want to create a matrix form of this cellArray and extract first column.
(334-352-404-414)
cellArray2=
' N334 4261461.0645 2661117.6797 3918916.0472'
' N352 4266205.852 2659683.96 3914798.2885'
' N404 4258400.8221 2662966.354 3920634.872'
' N414 4255211.3943 2666063.0462 3921735.7546'
%I wanna extract first column of this cellArray2 if we think this is a matrix.
(N334-N352-N404-N414)

 채택된 답변

cellArray ={' 334 4261461.0645 2661117.6797 3918916.0472'
' 352 4266205.852 2659683.96 3914798.2885'
' 404 4258400.8221 2662966.354 3920634.872'
' 414 4255211.3943 2666063.0462 3921735.7546'};
out1 = regexp(cellArray,'(?<=^\s*)\d*','match');
out1 = cat(1,out1{:});
cellArray2 ={' N334 4261461.0645 2661117.6797 3918916.0472'
' N352 4266205.852 2659683.96 3914798.2885'
' N404 4258400.8221 2662966.354 3920634.872'
' N414 4255211.3943 2666063.0462 3921735.7546'};
out2 = regexp(cellArray2,'N\d*','match');
out2 = cat(1,out2{:});

추가 답변 (0개)

카테고리

도움말 센터File 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