2015-07-03 212 views
0

我總是使用matlab來獲取FRED數據,但現在我無法再得到它了。 一個簡單的代碼,如: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

調試取功能,它創建了該URL是好的,但在第48行,當它使用urlread結果是:

301 Moved Permanently

Moved Permanently

The document has moved here.

什麼建議嗎?

謝謝

+0

@David_Kelley這裏是同樣的事情。該網址工作正常(下載txt),但urlread不起作用。上週它運行良好。你不覺得它是一個FRED API錯誤嗎? – ranthero

回答

1

看來,FRED不喜歡非HTTPS請求。我得到了你在Matlab 2015a中報告的同樣的錯誤,但是如果你將URL更改爲https,那麼它工作正常。

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

如果採取Matlab軟件從FRED請求並將其粘貼到瀏覽器的網址,你會得到一個有效的響應(我猜Chrome正在做的事情遵循的301錯誤爲您提供同時鏈接Matlab只是放棄了)。他們仍然允許來自其API服務的非HTTPS請求,但基本Matlab fetch函數不使用實際的FRED API。

更新:我剛剛收到以下電子郵件弗雷德:

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 [email protected] or 314-444-FRED (3733) if you have questions or concerns. Thanks for using FRED and the FRED API.

Sincerely,

The FRED Team

+0

工作!謝謝 – ranthero