Matlab FRED数据导入(获取错误)

Matlab FRED data import (fetch error)

我一直用matlab来获取FRED数据,但现在无法获取了。 一个简单的代码,如:

c = fred('http://research.stlouisfed.org/fred2/');
d = fetch(c,'DEXUSEU');

得到错误: 索引超出矩阵维度。

Error in fred/fetch (line 93) d.Data = [datenum(str2num(tmp(:,1:4)),str2num(tmp(:,6:7)),str2num(tmp(:,9:10))) str2num(tmp(:,11:end))]; %#ok

调试fetch函数,它创建的url没问题,但是在第48行使用url读取结果是:

301 Moved Permanently

Moved Permanently

The document has moved here.

有什么建议吗?

谢谢

FRED 似乎不喜欢非 HTTPS 请求。我得到了你在 Matlab 2015a 中报告的相同错误,但是如果你将 url 更改为 https,它工作正常。

c = fred('https://research.stlouisfed.org/fred2/');
d = fetch(c,'DEXUSEU');

如果你把 Matlab 从 FRED 请求的 url 粘贴到 Chrome,你会得到一个有效的响应(我猜 Chrome 正在做一些事情按照 301 错误为您提供的 link 而 Matlab 刚刚放弃)。他们仍然允许来自他们的 API 服务的非 HTTPS 请求,但是基本的 Matlab fetch 函数不使用实际的 FRED API.

更新:我刚刚收到来自 FRED 的以下电子邮件:

FRED API requires HTTPS.

Beginning on August 18, 2015, the FRED API will require HTTPS requests. This change will help provide secure communication with the FRED API. An automatic redirect will forward HTTP requests to HTTPS. We recommend that you update the URLs in your code. The API currently supports HTTPS to allow you to test your applications with this secure protocol.

Please contact us at STLS.RSRCHWebmaster@stls.frb.org or 314-444-FRED (3733) if you have questions or concerns. Thanks for using FRED and the FRED API.

Sincerely,

The FRED Team