MATLAb creating variables from ascii document

  • MATLAB
  • Thread starter gryphon1221
  • Start date
  • #1
Hi, I have a document with a whole bunch of header information and description. After about 20 lines it goes into the useful data. Each line of data is formatted like this:

P 1 1234.939 1234.505 1234.505 102

where P just denotes that it is data, 1 is a satellite number and the data is X Y Z and time.

Does anybody know how to import this data into useful variables X Y Z and time? I am thinking it will be textscan or something, but I have never used data in this format before. Thanks for any help.
 

Answers and Replies

  • #2
Dr Transport
Science Advisor
Insights Author
Gold Member
2,548
704
read each line, break it up on a blank space using regular expressions and put each entry into the correct variable.
 
  • #3
360
1
I'm pretty sure there's an easier way. A command that does it in one hit. But I forget.
 
  • #5
f95toli
Science Advisor
Gold Member
3,323
822
I this case you can use dlmread
Much easier than fscanf etc

Just skip the.initial rows( the header) and the first column.
 

Related Threads on MATLAb creating variables from ascii document

  • Last Post
Replies
2
Views
2K
Replies
1
Views
15K
  • Last Post
Replies
6
Views
7K
Replies
1
Views
2K
Replies
8
Views
2K
S
Replies
4
Views
2K
Replies
2
Views
10K
Replies
1
Views
4K
Top