How to load .asc file into an array
3 ビュー (過去 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!