Importing data from a text file in matrix form
古いコメントを表示
I have a text file (extracted from ANSYS as stiffness matrix)from which I want to obtain a 1710x1710 matrix.Since the text file large,I am attaching it in two parts(as zip files:part-I and part-II).Just copy the second part and paste at the end of first part.Here is part-I.
- The answer should not only work for 1710x1710 case but for all sizes * ( obviously the text format will remain the same )*
5 件のコメント
Kamal Bera
2015 年 4 月 22 日
Guillaume
2015 年 4 月 22 日
Can you change the way the file is written so that the index does not collide with the value when the value is negative, that is avoid things like:
5-0.22349156E+04
Kamal Bera
2015 年 4 月 22 日
Guillaume
2015 年 4 月 22 日
Your text file is basically consisting of fixed width columns. This is a bit more difficult to parse in matlab since there's no built-in function for that. You can either read each line and split them at constant columns or use a regular expression as per Stephen's answer.
Stephen23
2015 年 4 月 22 日
While regexp is used in my answer, actually a cunning use of sscanf splits that adjacent data. It relies on the fact that it there is either a space or a minus sign...
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Text Data Preparation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!