MATLAb creating variables from ascii document

  • MATLAB
  • Thread starter gryphon1221
  • Start date
  • #1

Main Question or Discussion Point

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
Gold Member
2,330
446
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.
 
  • #4
Dr Transport
Science Advisor
Gold Member
2,330
446
if each line is identical, can us a fscanf(.....);
 
  • #5
f95toli
Science Advisor
Gold Member
2,950
448
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

Replies
1
Views
2K
Replies
2
Views
10K
Replies
6
Views
5K
Replies
2
Views
3K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
5
Views
67K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
1
Views
8K
Top