MATLAB extract numbers in .txt file

3 replies · 2K views · last reply
member 428835
Hi PF!

I have a .txt file with spaces and letters, along with numbers. It looks something like this:

12.0 42.0 21.0 32.0
ICF-8-1
23.0 24.0 46.0 600.0

Additionally, the first two sets of numbers each represent a coordinate pair. Then the first coordinate is (12,42) and the second is (21,32) and so on. Does anyone know how I can have MATLAB extract this info? I've attached the .txt file so you can see what I'm looking at.

Thanks so much!
 
Attachments
joshmccraney said:
Hi PF!

I have a .txt file with spaces and letters, along with numbers. It looks something like this:

12.0 42.0 21.0 32.0
ICF-8-1
23.0 24.0 46.0 600.0

Additionally, the first two sets of numbers each represent a coordinate pair. Then the first coordinate is (12,42) and the second is (21,32) and so on. Does anyone know how I can have MATLAB extract this info? I've attached the .txt file so you can see what I'm looking at.

Thanks so much!

Did you try just using import data? It can sometimes parse things out nicely.
 
joshmccraney said:
Hi PF!

I have a .txt file with spaces and letters, along with numbers. It looks something like this:

12.0 42.0 21.0 32.0
ICF-8-1
23.0 24.0 46.0 600.0

Additionally, the first two sets of numbers each represent a coordinate pair. Then the first coordinate is (12,42) and the second is (21,32) and so on. Does anyone know how I can have MATLAB extract this info? I've attached the .txt file so you can see what I'm looking at.

Thanks so much!

Also depends on your version, newer versions have a nicer import data app. I got it to work in mine, but I had to delete the top characters manually.
 
  • Like
Likes   Reactions: member 428835