fetch
Request data from FRED data servers
Description
Examples
Connect to the FRED® data server using the URL 'https://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
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: SeriesID: "DEXUSEU" Data: [6955×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://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
c = fred(url);
Adjust the display data format for currency.
format bank
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: SeriesID: "DTB6" Data: [63×2 double]
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://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
c = fred(url);
Adjust the display data format for currency.
format bank
Retrieve historical data for the US / Euro Foreign Exchange Rate series.
series = 'DEXUSEU';
Fetch five months of data from January 1, 2007 through June 1, 2007.
startdate = '01/01/2007'; enddate = '06/01/2007'; d = fetch(c,series,startdate,enddate)
d = struct with fields: SeriesID: "DEXUSEU" Data: [109×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://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
c = fred(url);
Adjust the display format for currency.
format bank
Set the data return format to table using the DataReturnFormat
property of the fred
object.
c.DataReturnFormat = 'table';
Fetch all available daily foreign exchange rates between the US dollar and the Euro using the series 'DEXUSEU'
. The table d
contains one row for the series. Each variable describes a piece of information about the series.
series = 'DEXUSEU';
d = fetch(c,series)
d=1×2 table
SeriesID Data
_________ ______________
"DEXUSEU" {6955×2 table}
Display the first few foreign exchange rates. The first variable in the table is the date and the second variable is the foreign exchange rate. Also, the first variable is an array of MATLAB® date numbers.
head(d.Data{1})
Var1 Var2 _________ ____ 730124.00 1.18 730125.00 1.18 730126.00 1.16 730127.00 1.17 730128.00 1.16 730131.00 1.15 730132.00 1.15 730133.00 1.17
Close the FRED connection.
close(c)
Connect to the FRED data server using the URL 'https://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
c = fred(url);
Adjust the display format for currency.
format bank
Set the data return format to table using the DataReturnFormat
property of the fred
object. Also, set the date and time format to datetime
array using the DatetimeType
property.
c.DataReturnFormat = 'table'; c.DatetimeType = 'datetime';
Fetch all available daily foreign exchange rates between the US dollar and the Euro using the series 'DEXUSEU'
. The table d
contains one row for the series. Each variable describes a piece of information about the series.
series = 'DEXUSEU';
d = fetch(c,series)
d=1×2 table
SeriesID Data
_________ ______________
"DEXUSEU" {6955×2 table}
Display the first few foreign exchange rates. The first variable in the table is the date and the second variable is the foreign exchange rate. Also, the first variable is a datetime
array.
head(d.Data{1})
Var1 Var2 ___________ ____ 04-Jan-1999 1.18 05-Jan-1999 1.18 06-Jan-1999 1.16 07-Jan-1999 1.17 08-Jan-1999 1.16 11-Jan-1999 1.15 12-Jan-1999 1.15 13-Jan-1999 1.17
Close the FRED connection.
close(c)
Input Arguments
FRED connection, specified as a connection object created using
fred
.
FRED series, specified as a character vector or string scalar.
Example: 'DEXUSEU'
Data Types: char
| string
Date, specified as a datetime
value, matrix, character
vector, or string scalar. For details about the data types, see datetime
.
Data Types: double
| char
| cell
| datetime
| string
Start date in a date range, specified as a datetime
value, matrix, character vector, or string scalar. For details about the
data types, see datetime
.
Data Types: double
| char
| cell
| datetime
| string
End date in a date range, specified as a datetime
value, matrix, character vector, or string scalar. For details about the
data types, see datetime
.
Data Types: double
| char
| cell
| datetime
| string
Output Arguments
FRED data, returned as a structure, table, or timetable. For details about FRED data, see https://fred.stlouisfed.org/.
Version History
Introduced in R2006b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)