Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Data import
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Rouzbeh

Posts: 9
Registered: 9/7/12
Data import
Posted: Sep 28, 2012 11:37 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello,

I am trying to import a file into MATLAB (programmatically), but the file is not well formatted and I have to move around the file to get to where I want.

Please see below for an example of the file (can be both in .dat or .xlsx format):
__________________________________________
Offset
0.00E+00 0.00E+00 0.00E+00 0.00E+00

Scaling Factor
1.00E+00 1.00E+00 1.00E+00 1.00E+00

Start Data: 7/29/2011 3:30:36 PM 231 ms

Time var1 Time var2 Time var3 Time
0.00E+00 5.15E+01 0.00E+00 5.14E+01 0.00E+00 0.00E+00 0.00E+00
5.00E-04 5.15E+01 5.00E-04 5.14E+01 5.00E-04 0.00E+00 5.00E-04
1.00E-03 5.15E+01 1.00E-03 5.14E+01 1.00E-03 0.00E+00 1.00E-03
1.50E-03 5.15E+01 1.50E-03 5.14E+01 1.50E-03 0.00E+00 1.50E-03
2.00E-03 5.15E+01 2.00E-03 5.14E+01 2.00E-03 0.00E+00 2.00E-03
2.50E-03 5.15E+01 2.50E-03 5.14E+01 2.50E-03 0.00E+00 2.50E-03
__________________________________________________

The only things that I need are:
1) the Start date and time in the Start Data row
2) the headers and the numeric matrix below them (I had some formatted files and I used import data to import them with no problem).

What I am trying to do is to move the pointer to the start of the Start Data line and read that line and then move it again to the start of the data matrix.
I could not get the result I was looking for with 'fscanf'.

A few things to note:

1) The size of the matrix is not constant and could change from file to file.

2) I am reading a series of files, but assuming that I can get one working that shouldn't be a problem.

3) I would prefer to store the data for each file in a structure for future use.

Any help with this is greatly appreciated.
Rouzbeh



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.