use textscan on a subset of from large ascii file
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
hello,
i am trying to use the textscan function to open a large ascii file (2.5gb) and break the file up into smaller files.
the big file is the cru ts 3.1 world monthly temp data from jan 1901-dec2009 where each month is stored in 360x720. multiply that by 1308 (number of months in date range) and that is my big ascii file.
now my problem is that i cannot seem to find any documentation on how to use textscan to scan through the original file using a specified range (360x720).
the help does refer to the possiblity of opening large files and subsetting it but the examples show how to do it using a given number of characters but since this data has a range of 0-255 i cant set a fixed number of characters for each line.
fyi-i am able to use the textscan on smaller files and get the results i want but i only use textscan to read the entire file and not a subset of the data.
is textscan able to do what im hoping or is there another function? i searched and couldnt find anything suitable.
any help would be greatly appreciated.
thanks.
n
0 Commenti
Risposte (2)
Walter Roberson
il 16 Mag 2011
monthnumber = 17; %for example. First is 1
fid = fopen('YourDataFile.txt','rt');
monthcell = textscan(fid, repmat('%g',720), 360, 'HeaderLines', 360*(monthnumber-1), 'CollectOutput', 1);
fclose(fid);
Your data would then be the array monthcell{1}
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!