Extract only numbers from a text file
6 views (last 30 days)
I have a text file that contains a series of lines where each line is of the following form: s.CircleByCenterPerimeter(center=(9.7593, 11.2643), point1=(9.8851, 11.2643))
I would like to extract just the first and third numbers from this line of text, and therefore from each line in the text file.
I tried a couple of things using textread(), but I couldn't figure out how to do it.
Any input would be much appreciated. Thank you
Paolo on 12 Jul 2018
Edited: Paolo on 12 Jul 2018
str = 's.CircleByCenterPerimeter(center=(9.7593, 11.2643), point1=(9.8851, 11.2643))';
For your text file:
raw = fileread('yourfile.txt');
data = regexp(raw,'(?<=\()-?\d+\.?\d+','match')
data = reshape(data,2,);