View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Google Weather

4.5 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 2.45 KB File ID: #35370 Version: 1.6

Google Weather



29 Feb 2012 (Updated )

Get location specific weather data using Google's Weather API

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

 Google Weather
 Get location specific weather data using Google's Weather API
 1. gweather()
 2. gweather('place') Ex. gweather('Goa')
 3. gweather(lat,long) Ex. gweather(15.563,73.818)
(lat,long in decimal degrees)

 Besides printing the current conditions and the forecast, the function
 returns the forecast information in a structure. (Output)

Sample Output:
 Current Conditions:
  3°C, 86% Humidity, Light rain
 Thu: -7°C to 3°C, Icy
 Fri: 0°C to 2°C, Mostly Sunny
 Sat: 0°C to 10°C, Rain
 Sun: -6°C to 6°C, Cloudy
Apparently, the Google Weather XML Feed is not officially supported.
Use of lat,long often provides unreliable results.


This file inspired Get Geometric Location And Other Information.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
16 Jul 2015 Ikko

Ikko (view profile)

Google weather API has closed, and there is no URL any more, which is why we have an error.

Comment only
07 May 2015 kyana shayan

it doesn't work for me.
i got this message
Error using urlreadwrite (line 90)
The server did not find a resource to match this request.

Error in urlread (line 36)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});

Error in gweather (line 64)
data = urlread(url);
can anyone help me?

Comment only
21 Mar 2012 Sagar Aiya

Thanks Yuri Kotliarov and R for your suggestion about clc.

Thanks a lot Andrew Bliss!
That flaw went unnoticed for quite some time. One of the reasons being that low temperatures (forecasts) were retrieved in deg F and later converted into deg Celsius before printing. That way, I could get temperatures as low as 0 deg F (-17.78 deg C) but not any lower.

I've made necessary changes and will upload the file soon.

Comment only
20 Mar 2012 Andrew Bliss

Andrew Bliss (view profile)

A nice function. Parsing is generally good, but failed for negative temperatures when I ran it. To fix:

For CURRENT_CONDITIONS and FORECASTS change [\w\s\d_/<>=%":.]* to .*

For TEMP, LOWS, and HIGHS change [\d] to [-\d]

Also, not everyone will want an output structure. Get around that with:
function outputstruct = gweather...
...%(your whole function)
if nargout
outputstruct = Output;

09 Mar 2012 R

R (view profile)

I agree clc is bad practice for a function to be distributed, otherwise great job

Comment only
09 Mar 2012 Yuri K

Yuri K (view profile)

Cool! But clc is not a good practice in function.

01 Mar 2012 1.3

provision to supply geographical coordinates as arguments instead of a location name.

03 Mar 2012 1.4

Uploaded the updated gweather.m file which I forgot to upload during the previous update.

21 Mar 2012 1.6

- clc has been removed.
- Fixed the issue of negative temperatures as suggested by Andrew Bliss.

Contact us