MATLAB MATLAB extract numbers in .txt file

AI Thread Summary
The discussion revolves around extracting coordinate pairs from a .txt file using MATLAB. The file contains numerical data and letters, with the first two sets of numbers representing coordinate pairs. Users suggest utilizing MATLAB's import data feature, noting that newer versions have improved capabilities for data parsing. One user successfully managed to extract the data after manually deleting some top characters from the file. The conversation highlights practical solutions for handling data extraction in MATLAB.
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

Physics news on Phys.org
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 member 428835
Thanks Student100! This totally worked!
 

Similar threads

Back
Top