How to read fortran formatted data from a text file? (for example: 0.556802469135838D+00)
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I got a file with contents like follow:
- 0.139200617284040D+00
- 0.139200617284039D+00
- 0.556802469135838D+00
- 0.348001543210539D-01
I'd used matlab function like fscanf/textscan to read the file, while I failed. Beacuse the data use "D" rather than "E" to indicate double type, as fortran does.
Is there anyway that this problem could be fixed?
0 Kommentare
Antworten (1)
Geoff Hayes
am 1 Feb. 2015
Alexander - why not read in the data as strings, replace the D with an E using either strrep or regexp, and then convert the string to a double using str2num? An alternative would be to open the fire in a text editor and replace all occurrences of D with E and then load the file as before.
Siehe auch
Kategorien
Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!