简体   繁体   English

在Matlab / Octave中加载FRED季度数据

[英]Loading FRED quarterly data in Matlab/Octave

I am trying to load quarterly data from the US Federal Reserve, Economic Data (FRED) into Matlab (actually Octave, but that shouldn't make a difference right?). 我正在尝试将美联储经济数据(FRED)的季度数据加载到Matlab中(实际上是倍频程,但这不应该有所不同吗?)。

The problem is that the FRED lists quarterly dates in a different way, eg 2013 Q2 is: 2013-04-01 问题在于FRED以不同的方式列出季度日期,例如2013 Q2为:2013-04-01

When I download the data (Excel only) and convert to .csv, and then load this, the minuses are interpreter as new colums. 当我下载数据(仅限Excel)并转换为.csv,然后加载该文件时,缺点将解释为新的列。 So that I end up with a year, -month, and -1 column. 这样我就得到了年,月和-1列。

What is a good way to convert this to quarters for Matlab/Octave? 将其转换为Matlab / Octave的四分之一的好方法是什么?

You can specify the format in which your date strings are handled in matlab. 您可以指定在matlab中处理日期字符串的格式。 For example if xlsread reads your date as a 'yyyy-mm-dd' string, as seems to be the case in FRED: 例如,如果xlsread将您的日期读取为“ yyyy-mm-dd”字符串,那么在FRED中似乎就是这种情况:

dateStr1 = '2013-04-01';
date1 = datenum(dateStr1,'yyyy-mm-dd'); 

And if you wish to display the date in 'yyyy qq' format use datestr(date1,'yyyy qq') 如果您希望以“ yyyy qq”格式显示日期,请使用datestr(date1,'yyyy qq')

Conversely, 反过来,

dateStr2 = '2013 Q2';
date2 = datenum(dateStr2,'yyyy qq');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM