MATLAB extract numbers in .txt file

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    File Matlab Numbers
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
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   Reactions: member 428835