Importing data from a text file in matrix form
Ältere Kommentare anzeigen
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 Kommentare
Kamal Bera
am 22 Apr. 2015
Guillaume
am 22 Apr. 2015
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
am 22 Apr. 2015
Guillaume
am 22 Apr. 2015
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
am 22 Apr. 2015
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...
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Text Data Preparation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!