MATLAB MATLAb creating variables from ascii document

  • Thread starter Thread starter gryphon1221
  • Start date Start date
  • Tags Tags
    Matlab Variables
AI Thread Summary
To import data from an ASCII document into MATLAB variables, users can utilize functions like textscan or dlmread. The data begins after the first 20 lines, formatted with a prefix indicating the data type, followed by satellite number and coordinates. Regular expressions can help break each line into components, but simpler methods like fscanf may also be effective if the format is consistent. It is recommended to skip the initial header rows and the first column to streamline the process. Overall, there are multiple approaches to efficiently extract and assign the data to variables X, Y, Z, and time.
gryphon1221
Messages
9
Reaction score
0
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.
 
Physics news on Phys.org
read each line, break it up on a blank space using regular expressions and put each entry into the correct variable.
 
I'm pretty sure there's an easier way. A command that does it in one hit. But I forget.
 
if each line is identical, can us a fscanf(...);
 
I this case you can use dlmread
Much easier than fscanf etc

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

Similar threads

Replies
5
Views
2K
Replies
4
Views
1K
Replies
3
Views
2K
Replies
3
Views
7K
Replies
2
Views
3K
Replies
8
Views
2K
Back
Top