PDA

View Full Version : MATLAb creating variables from ascii document


gryphon1221
Nov20-11, 01:58 PM
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.

Dr Transport
Nov20-11, 07:20 PM
read each line, break it up on a blank space using regular expressions and put each entry into the correct variable.

Unrest
Nov21-11, 07:26 PM
I'm pretty sure there's an easier way. A command that does it in one hit. But I forget.

Dr Transport
Nov24-11, 12:28 PM
if each line is identical, can us a fscanf(.....);

f95toli
Nov24-11, 12:36 PM
I this case you can use dlmread
Much easier than fscanf etc

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