Get Historical Weather Data

Version 0.5 (14.4 KB) by Julio Barros
MATLAB function to fetch historical weather information from NCEI-API.
Updated 4 Jun 2021



This function get historical weather data from NCEI API in MATLAB

This is a simple, proof-of-concept to easily fetch weather data in MATLAB. The output is set to JSON, and matlab conveniently packs the weather data into a struct datatype, making it easy to handle the data.

For this code, it uses the Global Surface Summary of the Day (GSOD) dataset, and the Naha statation (47936099999) to fetch temperatures and sea level pressure data. For more information on the dataset, visit

It should be easy to modify the code to suit other weather data and dataset needs. For more infomatio, visit NCEI API website


[Tmin,Tmax,Tmean,seaLevelPressure,stationPressure] = getHistoricalWeatherData(Date)

The input Date can be a MATLAB date datatype, as e.g.:

Date = datetime('today');

You can also add a start and end date:

Date = [datetime('2020-05-30') datetime('2021-05-30')];


You can either clone the repository, download the release as zip file, or visit View get-historical-weather-data on File Exchange

Cite As

Julio Barros (2024). Get Historical Weather Data (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.