Yahoo! Weather
YWEATHER(LOCATION) queries the Yahoo! Weather RSS feed for the specified location, and returns a struct containing the queried information.
The first input argument LOCATION can be one or more (U.S.) ZIP Codes or Location IDs. It can be a string, a vertical char array, or a vertical cell array of strings. To determine s Location ID, visit http://weather.yahoo.com/ and browse or search for the relevant location(s).
The second argument UNIT is optional, and can be either 'f' for Fahrenheit or 'c' for Celsius. It can be a single char string, a vertical char array, or a vertical cell array of strings. Yahoo! Weather's default value for UNIT is 'f'.
For more information about the RSS feeds and the data contained within them, visit http://developer.yahoo.com/weather/.
Data is acquired in XML format, after which it is converted into a struct using the xml_parse function. This function is available in the XML Toolbox by Marc Molinari on the MATLAB Central File Exchange (File ID 4278).
EXAMPLES:
Example 1: Using a ZIP Code.
yweather('10001') returns a 1x1 struct having fields (among others):
yweather_location.city: 'New York'
yweather_atmosphere.humidity: 50
yweather_astronomy.sunrise: '6:06 am'
item.yweather_condition.temp: 35
item.yweather_condition.date: 'Thu, 16 Mar 2006 2:51 am EST'
Example 2: Using a Location ID and (optional) unit.
yweather('UKXX0085','c') returns a 1x1 struct.
Example 3: Using a cell array of three locations.
yweather({'90028';'14850';'CAXX0301'}) returns a 3x1 struct.
Example 4: Using a char array of two ZIP Codes.
yweather(['56711';'33040']) returns a 2x1 struct.
Example 5: Using a cell array of three locations, in degrees Celsius.
yweather({'98381';'USCA0715';'04652'},'c') returns a 3x1 struct.
Example 6: Using a cell array of two locations, in variable units.
yweather({'27949';'UKXX0061'},{'f';'c'}) returns a 2x1 struct.
[Please subscribe to this file if you use it, so you can be notified of updates.]
Cite As
Skynet (2024). Yahoo! Weather (https://www.mathworks.com/matlabcentral/fileexchange/10414-yahoo-weather), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Data Import and Analysis > Data Import and Export > Web Access and Streaming > Web Services >
- Sciences > Geoscience > Weather and Atmospheric Science >
Tags
Acknowledgements
Inspired: Yahoo Weather - GUI, UIWEATHER ( www.weather.com )
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Removed extra line breaks, and added hyperlinks to relevant error messages. |