MATLAb creating variables from ascii document

  • Context: MATLAB 
  • Thread starter Thread starter gryphon1221
  • Start date Start date
  • Tags Tags
    Matlab Variables
Click For Summary
SUMMARY

The discussion focuses on importing data from an ASCII document into MATLAB variables. The data format includes a header followed by lines containing satellite data, specifically formatted as "P 1 1234.939 1234.505 1234.505 102". Users recommend using the textscan function for flexible data reading, while fscanf and dlmread are suggested for more structured data. The key takeaway is to skip initial header rows and the first column to effectively extract the relevant data.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of ASCII data formats
  • Knowledge of regular expressions
  • Basic concepts of data import functions in MATLAB
NEXT STEPS
  • Explore the textscan function in MATLAB for advanced data parsing
  • Learn about fscanf for structured data reading
  • Investigate dlmread for importing delimited data files
  • Study regular expressions in MATLAB for data manipulation
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and researchers who need to import and manipulate satellite data from ASCII files efficiently.

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 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K