How to import .dat files (comprising multiple columns which can only be copied and pasted all at the same time) into MATLAB?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jan
el 2 de Mzo. de 2016
Are you in the correct folder?
DataPath = 'C:\Temp'; % Adjust accordingly!
fid = fopen(fullfile(DataPath, '0002_03.dat'), 'r')
2 comentarios
Jan
el 3 de Mzo. de 2016
Editada: Jan
el 3 de Mzo. de 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.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!