You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
A MATLAB reader for GRIB1 data has been developed based on wgrib1.c (ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/wgrib.c), which has been wrapped in a MATLAB mexFunction. Using the reader, you can read GRIB1 data directly in MATLAB. I have tested it with the NLDAS-2 forcing data. It is much faster than all “MATLAB GRIB’ toolboxes/scripts I found from internet. The reader only for GRIB1 data. If you want, you can cook one for GRIB2 similarly.
You are welcome to use/test it. If there is any problem on the MATLAB side, I will be happy to help. The following is a simple instruction:
Compile the code: mex readGRIB1.c within matlab, you get “readGRIB1.mexa64” if you work on a 64-bit linux system.
Make a symbolic link of readGRIB1.mexa64 or copy it to your working directory
You may call readGRIB1 in you matlab code/command line window like the following line:
[data, nx, ny]=readGRIB1('2014102309.nldasforce-b.grb',2);
in which, “2” is the record number of the GRIB variable. What you need to do is just to figure out the record number of your variable in GRIB file.
Have fun!
Cite As
Shugong Wang (2026). Efficient GRIB1 data reader (https://www.mathworks.com/matlabcentral/fileexchange/53705-efficient-grib1-data-reader), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (351 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | email update A memory leak has been fixed. |
