MATLAB: I have a char data. I want to extract first column from this char data.

char data

%for example,
out1 =
p.11 109 820 109
p.12 503 159 117
p.13 234 207 151
p.14 139 134 215
Name Size Bytes Class Attributes
out1 1x188 376 char global
% what I want is that extract the first column if we think as a matrix. (p.11,p.12,p.13,p.14) %also, the first column would include only numbers so I need the codes which works both number and number-character mixed.
thanks in advance

Best Answer

If out1 is your string:
pgs = char(regexp(out1,'p\.\d+','match'));
Note that this requires out1 be a 1xn array, which it looks like it is. The reason for the char command is that regexp returns a cell array of matching strings. If a cell array works for you, just remove the char function.