Code covered by the BSD License  

Highlights from
Yahoo! Weather

4.0

4.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 3.97 KB File ID: #10414

Yahoo! Weather

by Skynet

 

17 Mar 2006 (Updated 08 Jan 2007)

Get location specific weather data from Yahoo! Weather.

| Watch this File

File Information
Description

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.]

Acknowledgements
This submission has inspired the following:
Yahoo Weather - GUI, UIWEATHER ( www.weather.com )
MATLAB release MATLAB 7.3 (R2006b)
Other requirements XML Toolbox by Marc Molinari: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4278&objectType=file
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
20 Mar 2006 Aravind Seshadri

Nice one!

Please login to add a comment or rating.
Updates
21 Mar 2006

Added implicit support for char and cell array inputs.

08 Jan 2007

Removed extra line breaks, and added hyperlinks to relevant error messages.

Tag Activity for this File
Tag Applied By Date/Time
external interface Skynet 22 Oct 2008 08:18:51
atmosphere Skynet 22 Oct 2008 08:18:51
climate Skynet 22 Oct 2008 08:18:51
meteorology Skynet 22 Oct 2008 08:18:51
temperature Skynet 22 Oct 2008 08:18:51
weather Skynet 22 Oct 2008 08:18:51
yahoo Skynet 22 Oct 2008 08:18:51

Contact us at files@mathworks.com