Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB extract numbers in .txt file

  1. Nov 17, 2016 #1

    joshmccraney

    User Avatar
    Gold Member

    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!
     

    Attached Files:

  2. jcsd
  3. Nov 17, 2016 #2

    Student100

    User Avatar
    Education Advisor
    Gold Member

    Did you try just using import data? It can sometimes parse things out nicely.
     
  4. Nov 17, 2016 #3

    Student100

    User Avatar
    Education Advisor
    Gold Member

    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.
     
  5. Nov 18, 2016 #4

    joshmccraney

    User Avatar
    Gold Member

    Thanks Student100! This totally worked!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: MATLAB extract numbers in .txt file
Loading...