필터 지우기
필터 지우기

How to extract information on year when data is in quarterly format

조회 수: 1 (최근 30일)
Raamasrinivas Venkata
Raamasrinivas Venkata 2019년 10월 30일
편집: Nicolas B. 2019년 10월 30일
My data is in the following format:
Year
1971-Q1
1971-Q2
1971-Q3
1971-Q4
1972-Q1
1972-Q2
1972-Q3
1972-Q4... until the 4th quarter of 2018. I have data on inflation and unemployment for this period and would like to plot it in the same graph with 'Year' on the xaxis. How do I extract only the years to a seperate variable, ie, the first four numbers of the variable 'Year' ?

답변 (1개)

Nicolas B.
Nicolas B. 2019년 10월 30일
편집: Nicolas B. 2019년 10월 30일
have you thought about using extractBefore() function?
For example:
function year = extractYear(s)
year = str2double(extractBefore(s, '-'));
end

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by