PLEASE HELP! HOW TO SOLVE THIS ASCII FILE
Show older comments
So, I just download altimetry data which have asc format and I need to change NaN data into several number. But I dont know where to start because matlab is new to me. When I convert to excel, this file have 5 columns, and 709 rows. Let me know your answer :) Pls I need your help..
6 Comments
Walter Roberson
on 18 Jul 2018
What is the difference between this question and your earlier https://www.mathworks.com/matlabcentral/answers/410825-need-help-fast-i-have-several-problem-about-ascii-file ?
The file you attached is not ascii format.
della tan
on 18 Jul 2018
della tan
on 18 Jul 2018
Walter Roberson
on 18 Jul 2018
zip it and attach the .zip
della tan
on 18 Jul 2018
Walter Roberson
on 20 Jul 2018
Please do not close questions that have an answer.
Answers (1)
Walter Roberson
on 18 Jul 2018
t = readtable('j3p0001c073.asc', 'readvar', false, 'HeaderLines', 74, 'FileType','text', 'treatasempty', '*');
13 Comments
della tan
on 18 Jul 2018
della tan
on 18 Jul 2018
Walter Roberson
on 18 Jul 2018
It worked fine for me in R2018a.
Are you using a MATLAB release R2013a or earlier?
ncol = 66;
fmt = repmat('%f', 1, ncol);
filename = 'j3p0001c073.asc';
fid = fopen(filename, 'rt');
data = cell2mat( textscan(fid, fmt, 'HeaderLines', 74, 'CollectOutput',10, 'TreatAsEmpty', '*') );
fclose(fid);
della tan
on 18 Jul 2018
Edited: Walter Roberson
on 18 Jul 2018
Walter Roberson
on 18 Jul 2018
What is the error message?
I just tried the code in R2013a on my system; it appears to work fine.
della tan
on 19 Jul 2018
Walter Roberson
on 19 Jul 2018
Ah, should be 1 after the 'CollectOutput', but that will not cause an error.
What is the error message? Does it say something about invalid property? Does it say something about an error converting cell arrays? Please show us everything that shows up in red.
della tan
on 19 Jul 2018
Walter Roberson
on 19 Jul 2018
Invalid file identifier means that it was not able to open a file with that name.
To check: You did unzip jason3.zip into the directory you are running the code from?
After you unzip, the following files should be in the directory:
j3p0001c070.asc
j3p0001c071.asc
j3p0001c072.asc
j3p0001c073.asc
j3p0001c074.asc
j3p0001c075.asc
j3p0001c076.asc
j3p0001c077.asc
j3p0001c078.asc
j3p0001c079.asc
j3p0001c080.asc
j3p0001c081.asc
j3p0001c082.asc
j3p0001c083.asc
j3p0001c084.asc
j3p0001c085.asc
j3p0001c086.asc
j3p0001c087.asc
j3p0001c088.asc
j3p0001c089.asc
j3p0051c070.asc
j3p0051c071.asc
j3p0051c072.asc
j3p0051c073.asc
j3p0051c074.asc
j3p0051c075.asc
j3p0051c076.asc
j3p0051c077.asc
j3p0051c078.asc
j3p0051c079.asc
j3p0051c080.asc
j3p0051c081.asc
j3p0051c082.asc
j3p0051c083.asc
j3p0051c084.asc
j3p0051c085.asc
j3p0051c086.asc
j3p0051c087.asc
j3p0051c088.asc
j3p0051c089.asc
della tan
on 19 Jul 2018
della tan
on 19 Jul 2018
della tan
on 19 Jul 2018
Walter Roberson
on 20 Jul 2018
save with the -ascii flag.
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!