import data .txt file in matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
KSSV
2017년 11월 23일
fid = fopen('my text file');
S = textscan(fid,'%s','Delimiter','\n','headerlines',3) ;
fclose(fid) ;
data = cell2mat(cellfun(@str2num,S{1},'un',0))
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!