Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

fetch

Request data from FRED data servers

Syntax

Description

example

d = fetch(c,series) returns FRED® data using the FRED connection c and the specified FRED series.

example

d = fetch(c,series,date) returns FRED data for a specific date.

example

d = fetch(c,series,startdate,enddate) returns FRED data for the date range from startdate through enddate.

Examples

collapse all

Connect to the FRED® data server using the URL 'https://research.stlouisfed.org/fred2/'.

url = 'https://research.stlouisfed.org/fred2/';
c = fred(url);

Fetch all available daily foreign exchange rates between the US dollar and the Euro using the series 'DEXUSEU'.

series = 'DEXUSEU';
d = fetch(c,series)
d = 

  struct with fields:

                 Title: ' U.S. / Euro Foreign Exchange Rate'
              SeriesID: ' DEXUSEU'
                Source: ' Board of Governors of the Federal Reserve System...'
               Release: ' H.10 Foreign Exchange Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' U.S. Dollars to One Euro'
             DateRange: ' 1999-01-04 to 2016-07-08'
           LastUpdated: ' 2016-07-11 3:41 PM CDT'
                 Notes: ' Noon buying rates in New York City for cable tra...'
                  Data: [4570×2 double]

d.Data is an N-by-2 double array that contains dates in the first column and the series values in the second column.

Close the FRED® connection.

close(c)

Connect to the FRED® data server using the URL 'https://research.stlouisfed.org/fred2/'.

url = 'https://research.stlouisfed.org/fred2/';
c = fred(url);

Fetch data for a day three months ago using the series 'DTB6'.

series = 'DTB6';
date = floor(now)-90;
d = fetch(c,series,date)
d = 

  struct with fields:

                 Title: ' 6-Month Treasury Bill: Secondary Market Rate'
              SeriesID: ' DTB6'
                Source: ' Board of Governors of the Federal Reserve System...'
               Release: ' H.15 Selected Interest Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' Percent'
             DateRange: ' 1958-12-09 to 2016-07-11'
           LastUpdated: ' 2016-07-12 3:46 PM CDT'
                 Notes: ' Discount Basis'
                  Data: [736434 0.3600]

d.Data is an N-by-2 double array that contains the date in the first column and the series value in the second column.

Close the FRED® connection.

close(c)

Connect to the FRED® data server using the URL 'https://research.stlouisfed.org/fred2/'.

url = 'https://research.stlouisfed.org/fred2/';
c = fred(url);

Fetch five months of data from January 1, 2007 through June 1, 2007.

series = 'DEXUSEU';
startdate = '01/01/2007';
enddate = '06/01/2007';
d = fetch(c,series,startdate,enddate)
d = 

  struct with fields:

                 Title: ' U.S. / Euro Foreign Exchange Rate'
              SeriesID: ' DEXUSEU'
                Source: ' Board of Governors of the Federal Reserve System...'
               Release: ' H.10 Foreign Exchange Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' U.S. Dollars to One Euro'
             DateRange: ' 1999-01-04 to 2016-07-08'
           LastUpdated: ' 2016-07-11 3:41 PM CDT'
                 Notes: ' Noon buying rates in New York City for cable tra...'
                  Data: [110×2 double]

d.Data is an N-by-2 double array that contains dates in the first column and the series values in the second column.

Close the FRED® connection.

close(c)

Related Examples

Input Arguments

collapse all

FRED connection, specified as a connection object created using fred.

FRED series, specified as a character vector.

Example: 'DEXUSEU'

Data Types: char

Date, specified as a datetime value, matrix, or date character vector. For details about the data types, see datenum.

Data Types: double | char | cell | datetime

Start date in a date range, specified as a datetime value, matrix, or date character vector. For details about the data types, see datenum.

Data Types: double | char | cell | datetime

End date in a date range, specified as a datetime value, matrix, or date character vector. For details about the data types, see datenum.

Data Types: double | char | cell | datetime

Output Arguments

collapse all

FRED data, returned as a structure. For details about FRED data, see https://research.stlouisfed.org/fred2/.

See Also

| |

Introduced in R2006b

Was this topic helpful?