Reputation: 5571
I want to read weather data from Weather Unground into Matlab directly. For a given site you can select to output the data in comma delimited format. How can I write a Matlab function that will read in the information into Matlab? I don't want to download the file but rather read it in from the URL.
For example, here is a URL of some data. Is there some Matlab function that has a URL as an input and saves data from whatever it finds there?
Upvotes: 2
Views: 11300
Reputation: 125864
The function URLREAD is what you're looking for. For example, using your URL above gives the following output:
>> str = urlread('http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MC9780&format=1');
str =
Time,TemperatureF,DewpointF,PressureIn,WindDirection,WindDirectionDegrees,WindSpeedMPH,WindSpeedGustMPH,Humidity,HourlyPrecipIn,Conditions,Clouds,dailyrainin,SoftwareType<br>
2010-09-27 00:09:00,56.0,52.0,30.05,NNE,25,0.0,3.0,86,0.00,,,0.00,,
<br>
2010-09-27 00:17:00,56.0,52.0,30.05,NNE,25,0.0,3.0,86,0.00,,,0.00,,
<br>
2010-09-27 00:28:00,56.0,52.0,30.04,NNE,30,2.0,5.0,85,0.00,,,0.00,,
<br>
...
Now you just have to parse the string output to get the information you want.
If you would rather read from the URL and save it to a file instead of loading it as a string variable, you can use the function URLWRITE.
Upvotes: 5