How to read a matrix from an ASCII file?
조회 수: 6 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2012년 6월 11일
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
Walter Roberson
2012년 6월 11일
Nothing works? You are not able to fopen() the file and fgetl() a line at a time and display the line ?
참고 항목
카테고리
Help Center 및 File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!