MATLAB Answers

Importing arbitrary assymetric matrix

1 view (last 30 days)
Rafael
Rafael on 15 Oct 2013
Commented: Rafael on 15 Oct 2013
Hello,
I need to import data from a file like that in Matlab
825.077985928 , 803.976586577 , 7.94328234724E+6
746.602923264 , 746.380023451 , 8.91250938134E+6
669.973486472 , 685.594867998 , 1.E+7
608.553696091 , 622.808380226 , 1.1220184543E+7
535.301644385 , 564.919488252 , 1.25892541179E+7
0 0 3.8 2 0 0 0 0 .1 .1 5 5 4 4 20 14 142 13 Sep 1900 10:24:07 519 LSGM 1 AG 0 100 0 0 0 0 5 0 0000 ¯Z'(E4 ) ¯Z"(E4 ) 13.49+25
I have tried to use many functions of matlab, therefore it have not worked! I would be very grateful if anyone could help me.
Thanks in advance!

Answers (2)

Walter Roberson
Walter Roberson on 15 Oct 2013
Which parts are always the same length and which parts are variable length?
MATLAB does not offer any tools to automatically import files that have different input formats for different lines. The more the lengths are fixed and the formats are fixed, the easier it is to work with the existing tools.
  1 Comment
Rafael
Rafael on 15 Oct 2013
All data have three colums delimited by ','... Therefore, the last line have an arbitrary format. The problem is that I have hundreds of files like that. Actually, they are generated by conversion of HP format to IBM format using LifUtilities... So, I would like to be able to delete last line or to avoid to read last line.

Sign in to comment.


Jie
Jie on 15 Oct 2013
Edited: Jie on 15 Oct 2013
try
textscan()
or
strread()
but as Walter posted, "The more the lengths are fixed and the formats are fixed, the easier it is to work with the existing tools."
  1 Comment
Rafael
Rafael on 15 Oct 2013
My probelm is the last line that have an arbitrary format. The problem is that I have hundreds of files like that. Actually, they are generated by conversion of HP format to IBM format using LifUtilities... So, I would like to be able to delete last line or to avoid to read last line.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by