Extract data from ASCII format

6 ビュー (過去 30 日間)
Majid Mohamod
Majid Mohamod 2018 年 4 月 11 日
コメント済み: Majid Mohamod 2018 年 10 月 26 日
Hi all, I have GLDAS Land Water Content (monthly) data. it says on the website that these data type are ASCII format. However, when I download the data the file extension is txt. Please, I need help to figure out a way to convert the file to csv format or xyz text file.
I have a script I used it before and it works very well to convert asc format but doesn't work with the current data! I attached one of the files The script here:
  2 件のコメント
Teresa
Teresa 2018 年 10 月 26 日
Hi Majid,
I just read your post and perhaps you may give me a few guidelines. I actually have an .asc file but I cannot accede it in matlab. I have tried the functions: 'importdata', 'fopen' to define a Fid and then 'textscan'. However, I am not acceding correctly the data as I am only getting the number of rows. Could you tell me which function were you using? Thank you in advance. Teresa
Majid Mohamod
Majid Mohamod 2018 年 10 月 26 日
Hi Teresa,
The following code has used to convert weather data (PERSSIAN, CDR and CSS) to csv format. I am not sure if it will work for you. Please, find the attachment.
Thanks, Majid

サインインしてコメントする。

採用された回答

KSSV
KSSV 2018 年 4 月 11 日
編集済み: KSSV 2018 年 4 月 11 日
fid = fopen('GLDAS_NOAH10_M.A200101.totalH2O.txt','r') ;
S = textscan(fid,'%f %f %f','HeaderLines',19) ;
fclose(fid) ;
x = S{1} ; y = S{2} ; z = S{3} ;
data = [x y z] ;
save 'myfile_xyz.txt' data -ascii
  1 件のコメント
Majid Mohamod
Majid Mohamod 2018 年 4 月 11 日
Thanks man so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by