How to read a matrix from an ASCII file?
7 views (last 30 days)
Show older comments
I have an ASCII file cuboid.mfd. It's content looks as follows:
Version : Marc Mentat 2010.1.0 (32bit)
=beg= 1 (magic)
1234
=end=
=beg= 2 (entities)
84
=end=
=beg= 3 (description)
=end=
=beg= 102 (nodes)
1 2.000000000000e+00 0.000000000000e+00 1.000000000000e+00
0 0
2 2.000000000000e+00 0.000000000000e+00 0.000000000000e+00
0 0
3 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00
0 0
=end=
=beg= 205 (elements)
1 8 0 8
1 2 3 4
13 17 21 25
0 0 0 0
0 0 0 0
=end=
I would like to use the 6x4 matrix (nodes) and the 5x4 matrix (elements) for further calculations. The number of rows and columns of both of the matrices may vary but the structure of the file is always the same. I haven't found any appropriate command to import them. There should be an easy way how to do it.
0 Comments
Answers (1)
Walter Roberson
on 11 Jun 2012
None of the built-in data importing commands can handle this, and there is no easy way to do it. You will need to use low-level I/O operations such as fopen(), fgetl(), fscanf(), fclose()
3 Comments
Walter Roberson
on 11 Jun 2012
Nothing works? You are not able to fopen() the file and fgetl() a line at a time and display the line ?
See Also
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!