unable to download data from FRED with Datafeed Toolbox

I'm unable to download data using the fred function. I've Matlab R13 and the Datafeed toolbox. I'm able to connect with the FRED website but unable to download the data with the code below. I understand there has been issues with the "http" and I've tried replacing it with "https". With the "https" I'm unable to connect so I kept the original "http" address and been able to connect.
c = fred('http://research.stlouisfed.org/fred2/series'); d = fetch(c,'DEXUSEU');
I'm getting the following error message:
ndex exceeds matrix dimensions.
Error in fred/fetch (line 94) d.Data = [datenum(str2num(tmp(:,1:4)),str2num(tmp(:,6:7)),str2num(tmp(:,9:10))) str2num(tmp(:,11:end))]; %#ok
Error in ChangeDetectionStudy6 (line 18) d = fetch(c,'DEXUSEU');

6 Comments

Testing in a latter version than yours, I find that the required URL is https://research.stlouisfed.org/fred2/ including the https and including ending in '/' . I find that using http does not work in current versions.
I work on FRED at the St. Louis Fed. In May we changed our URL from https://research.stlouisfed.org/fred2/series/ to https://fred.stlousifed.org/series/.
Can you try changing the URL to https://fred.stlousifed.org/series/?
I find in a recent version that I can use either
fred('https://research.stlouisfed.org/fred2/')
or
fred('https://fred.stlouisfed.org/')
but not
fred('https://fred.stlousifed.org/series/')
Perhaps fred() automatically adds on the 'series/' part
Thanks for your input.I tried, none of the above links worked.
Here is my code:
c=fred('https://research.stlouisfed.org/fred2/');
series = 'DTB6';
date = floor(now)-90;
d = fetch(c,series,date)
With the above code I don't even connect. However, if I use c=fred then I at least connect but then I get the "Index exceeds matrix dimensions" error.
Thanks.
I tested the code on version 2016a using both
fred('https://research.stlouisfed.org/fred2/')
or
fred('https://fred.stlouisfed.org/')
and it worked. A couple of possible issues come to mind.
  1. The version of Matlab that you are using does not support https requests in the datafeed toolbox. Was this working recently and then suddenly stopped?
  2. Do you need to connect through a proxy? Are you sure that you're connecting the to FRED servers. One way to test, would be to try using the datafeed toolbox to pull data from another website like Yahoo! Finance. https://www.mathworks.com/help/datafeed/yahoo.html
On 9/2021
I'm using Matlab2014 and I'm getting the same error reported in this thread back in 2017. Note that this used to work in the past (Windows7 OS). It appears that I'm not getting connection to https url. See code below:
>> url = 'https://research.stlouisfed.org/fred2/'
url =
https://research.stlouisfed.org/fred2/
>> c = fred(url);
Error using fred (line 64)
Unable to connect to given URL.
If I try http address however, this is the command line:
url = 'http://research.stlouisfed.org/fred2/'
c = fred(url);
gdp = fetch(c, 'GDPC1');
This is the error message:
Index exceeds matrix dimensions.
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

Sign in to comment.

Answers (1)

I would suggest upgrading to newer version of MATLAB. Otherwise, you may need to contact MathWorks technical support for alternative solutions. By the way, Datafeed Toolbox no longer support Yahoo! Finance API.

Categories

Products

Asked:

on 23 Jan 2017

Edited:

cy
on 8 Sep 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!