![]() |
使用URL将数据读入Matlab
我想将Weather Unground的天气数据直接读取到Matlab中。对于给定的站点,您可以选择以逗号分隔格式输出数据。如何编写将信息读入Matlab的Matlab函数?我不想下载文件,而是从URL读入。
例如,这是一些数据的[URL="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MC9780&format=1"]URL[/URL] 。是否有一些Matlab函数以URL作为输入并从那里找到的数据保存数据? [B]回答:[/B] 函数[URL="http://www.mathworks.com/help/techdoc/ref/urlread.html"]URLREAD[/URL]是您要寻找的。例如,使用上面的URL将给出以下输出: >> str = urlread('[url]http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MC9780&format=1');[/url] str = Time,TemperatureF,DewpointF,PressureIn,WindDirection,WindDirectionDegrees,WindSpeedMPH,WindSpeedGustMPH,Humidity,HourlyPrecipIn,Conditions,Clouds,dailyrainin,SoftwareType 2010-09-27 00:09:00,56.0,52.0,30.05,NNE,25,0.0,3.0,86,0.00,,,0.00,, 2010-09-27 00:17:00,56.0,52.0,30.05,NNE,25,0.0,3.0,86,0.00,,,0.00,, 2010-09-27 00:28:00,56.0,52.0,30.04,NNE,30,2.0,5.0,85,0.00,,,0.00,, ... 现在,您只需解析字符串输出即可获取所需的信息。 如果您希望从URL读取并将其保存到文件中,而不是将其作为字符串变量加载,则可以使用[URL="http://www.mathworks.com/help/techdoc/ref/urlwrite.html"]URLWRITE[/URL]函数。 [url=https://stackoverflow.com/questions/3807096]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 06:11。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.