How to load .asc file into an array
6 次查看(过去 30 天)
显示 更早的评论
My .asc pathway is loaded into MATLAB however the file itself isn't necessarily loading into my program. The first 30 lines are header information and then data that is about 1000x1000 with no spaces in between. It's spatial data. Ultimately I would like each spatial array to be put into a larger third dimensional array..
This is an example of what it looks like: 000000001111112222222...
Would I use textscan? This doesn't seem to work although I could be doing it wrong.. I currently have this:
Internet_pathname = strcat(recur_path,num2str(i),'/ims',num2str(i),num2str(j),'_',num2str(Res),'km.asc.gz');
ascFile= gunzip(Internet_pathname);
Fo = fopen(char(ascFile));
[a]=textscan(Fo,'%f')
0 个评论
回答(2 个)
Jan
2012-7-25
What do you expect as data for '000000001111112222222...'? Using '%f' treats this string as a large number. Do you want a UINT8 vector, which contains a 0 if the file contains the character '0'? Then:
value = fread(Fo, Inf, 'uchar=>uint8') - uint8('0');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!