I want to create three tables in Matlab Year,Month and Day and then concatenate into one column so that
1970 1 1
1970 1 2
.
.
.
1970 12 1

댓글 수: 1

Stephen23
Stephen23 2016년 9월 2일
Azzi Abdelmalek's answer is the fastest, neatest, and best solution to this question.

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2016년 9월 2일

0 개 추천

clc; clear all
iwant = [ ];
for i = 1:12
d = calendar(1970,i)' ;
d(d==0) = [] ;
d = d(:) ;
y = repmat(1970,[length(d) 1]) ; % year
m = repmat(12,[length(d) 1]) ; % month
ymd = [y m d] ;
iwant = [iwant ; ymd] ;
end
there could be some other elegant way..

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 9월 2일

2 개 추천

d1=datenum('01-01-1971','dd-mm-yyyy')
d2=datenum('31-12-1971','dd-mm-yyyy')
d=datevec(d1:d2)
d=d(:,1:3)

댓글 수: 2

KSSV
KSSV 2016년 9월 2일
Good one...
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2016년 9월 28일
It's awesome

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by