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 comentario

Stephen23
Stephen23 el 2 de Sept. de 2016
Azzi Abdelmalek's answer is the fastest, neatest, and best solution to this question.

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 2 de Sept. de 2016

0 votos

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..

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 2 de Sept. de 2016

2 votos

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 comentarios

KSSV
KSSV el 2 de Sept. de 2016
Good one...
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya el 28 de Sept. de 2016
It's awesome

Iniciar sesión para comentar.

Categorías

Más información sobre Language Fundamentals en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 2 de Sept. de 2016

Comentada:

el 28 de Sept. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by