How to import .dat files (comprising multiple columns which can only be copied and pasted all at the same time) into MATLAB?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm currently trying to import a .dat file (e.g.0002_03.dat) into MATLAB in order to logically arrange the data in a spreadsheet.
My issue is that, although the data in 0002_03.dat is nicely ordered into columns separated by spaces, it is impossible to select, copy and paste one column at a time (which would make my question redundant since, in that case, I wouldn't have to import the data into MATLAB in the first place - I could copy and paste each column into columns in Excel). If I try to select one column only, I end up selecting the entire dataset.
Thus far I have tried: import the .dat file in MATLAB using 'import' - the result is a 51x1 cell array; fid=fopen('0002_03.dat','r') which returned -1; textscan('0002_03','.xls') which returned 'Empty cell array: 1-by-0'
6 commentaires
Réponses (1)
Jan
le 2 Mar 2016
Are you in the correct folder?
DataPath = 'C:\Temp'; % Adjust accordingly!
fid = fopen(fullfile(DataPath, '0002_03.dat'), 'r')
2 commentaires
Jan
le 3 Mar 2016
Modifié(e) : Jan
le 3 Mar 2016
fid = 3 means, that Matlab has opened the file successfully. What does confuse you at this point? I think, this is a valid point to start from.
What was the problem with the data imported by the import function? I still do not understand, which problem you are struggeling with.
Voir également
Catégories
En savoir plus sur Spreadsheets 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!