how to import asc.gz into matlab
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
New to matlab and in need of some very basic/remedial help (it is beyond me). Trying to import asc.gz data into matlab. I have 5 folders (grid points), each folder contains 11 files (months) worth of hourly data (~8000 hours per grid point). This is the current file name for one month of one grid point 'C:\Users\osoli\Desktop\GF-EC_Spec_Opr_201307_GP007203.asc'
Below is an screenshot of the data in one hour. Any help is greatly appreciated.

0 comentarios
Respuestas (1)
Abderrahim. B
el 18 de Jul. de 2022
Editada: Abderrahim. B
el 18 de Jul. de 2022
For .gz file, you can use gunzip
Some examples can be found in this documentation page:
For .asc files there is no function to that directly, but you can use fopen with fclose.
Example
fid = fopen('YouFileName.asc', 'rt');
C = textscan(fid, '%s%s%f%f', 'Delimiter',',', 'HeaderLines', 1);
fclose(fid);
Maybe you can use fgetl() as an alternative but in this case you will need to read line by line.
Hope this helps
1 comentario
Walter Roberson
el 25 de Jul. de 2022
If you read the first line of the .asc using fgetl() then you can parse out the Num Freqs and Num Direncs
Skip the next 5 lines.
Construct a format that is Num Freqs copies of '%f' .
Construct a format that is '%*s' followed by the above format, followed by another %*s
textscan() with that format with a count of 1. The two skipped strings (%*s) will be 'freq' and 'anSpec' . The numeric values will be... I am not sure what they mean? But there will be (26) of them.
Construct a format that is %f followed by the 26 %f followed by %f . textscan() with that format and a repeat count that is the same as Num Direncs .
Likewise you can read in the last two lines, if you need them. It is not obvious to me what they mean or how many entries per line there are.
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!