import data .txt file in matlab
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hernaldo Leyton
il 22 Nov 2017
Commentato: Hernaldo Leyton
il 23 Nov 2017
Hello everyone, I have a problem when trying to open a .txt file this is as follows:
Friday 20th of December 2013 01:43:33 PM
Compound:PM10 emissions_ds_name:edgar_HTAPv2_TRANSPORT(EPA-USA-CAN+MICS+TNO+EDGAR) Year:2010 Month:January
lat lon emission 2010 1 (tons)
-55,5 -68,2 0,0188546
-55,5 -68,1 0,0188546
-55,4 -69,5 0,0188546
-55,4 -69,2 0,0188546
-55,4 -68,9 0,0188546
-55,4 -68,8 0,0188546
-55,4 -68,6 0,131982
I've tried it with the importdata function, but the result is only cell arrays with the data not separated (only one column).
I've tried it with the textscan function:
fid = fopen ('edgar_HTAP_PM10_emi_TRANSPORT_2010_1.txt');
data = textscan (fid, '% f% *% f% *% f');
fclose (fid);
and it only generates me arrays of empty cells.
Does anyone have any idea how to do it please?
I want the latitude, longitude and emissions data to be in separate columns
Thank you very much
0 Commenti
Risposta accettata
KSSV
il 23 Nov 2017
fid = fopen('my text file');
S = textscan(fid,'%s','Delimiter','\n','headerlines',3) ;
fclose(fid) ;
data = cell2mat(cellfun(@str2num,S{1},'un',0))
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Large Files and Big Data in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!