How to import data (text and numbers) from a tabuled .dat file in MATLAB?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jonatan Eisermann
le 4 Jan 2024
Commenté : Sulaymon Eshkabilov
le 5 Jan 2024
Hello everyone.
I need to read tabulated data from a file named 'Mechanism.dat,' which includes both numbers and words. Here are the first two lines of the .dat file as an example:
1.00 ch3och3 1.00 m 0.00 ND 1.00 ch3 1.00 ch3o 1.00 m 0.23E+20 -0.661 84139.
1.00 ch3och3 1.00 o2 0.00 ND 1.00 ch3och2 1.00 ho2 0.00 ND 0.41E+24 2.000 44910.
I tried using the command
table0 = readtable('Mechanism.dat', 'Delimiter', ' ', 'MultipleDelimsAsOne', true);
disp(table0)
however it replaces the words with the numerical value NaN. How can I overcome this issue?"
0 commentaires
Réponse acceptée
Sulaymon Eshkabilov
le 4 Jan 2024
It is reading ok:
% *.data can be uploaded and thus, .txt file format is taken. Both works
% table0 = readtable('Mechanism.dat', 'Delimiter', ' ', 'MultipleDelimsAsOne', true);
table0 = readtable('Mechanism.txt', 'Delimiter', ' ', 'MultipleDelimsAsOne', true);
disp(table0)
% Alt. way is readcell
table1 = readcell('Mechanism.txt', 'Delimiter', ' ', 'MultipleDelimsAsOne', true);
disp(table1)
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Large Files and Big Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!