필터 지우기
필터 지우기

import data .txt file in matlab

조회 수: 2 (최근 30일)
Hernaldo Leyton
Hernaldo Leyton 2017년 11월 22일
댓글: Hernaldo Leyton 2017년 11월 23일
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

채택된 답변

KSSV
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))
  댓글 수: 1
Hernaldo Leyton
Hernaldo Leyton 2017년 11월 23일
Thanks very much. I solved the problem with your suggested code

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by