Importing data from a text file in matrix form
Afficher commentaires plus anciens
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 commentaires
Kamal Bera
le 22 Avr 2015
Guillaume
le 22 Avr 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
le 22 Avr 2015
Guillaume
le 22 Avr 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
le 22 Avr 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...
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!