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

cell arrays

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)

Best Answer

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{:});