Definition of Time

I have a file data with:
Column1: Year (2011)
Column2: Month (10)
Column3: Day (22)
Column4: Hour (10)
Column5: Minute (35)
Column6: Second (30)
These are "86400x1 double" so a lot of data.
I want to have a variable or another cell with TIME like:
YYYY.MM.DD HH.MM.SS (2011.10.22 10.35.30)
How could I concatenate or merge all elements?
I need to use it after that to find the DATE and TIME (X) in the database and to delete until the next (Y) value TIME. At the end I have to plot all and have an average of temperatures (The data has also some columns with temperatures)
Thank you

3 comentarios

Jan
Jan el 7 de Mzo. de 2012
I do not understand the input format. What is "these" in "these are 86400x1"? How does the file look like and what means "*another* cell"? And what exactly means "YYYY.MM.DD HH.MM.SS (2011.10.22 10.35.30)"? Do you want the 'YYYY...' string appear in the variable? And the parenthesis?
I suggest to use one of the standard date formats, see "help datestr".
Liviu
Liviu el 7 de Mzo. de 2012
Input format is 6 columns and 86400 rows. It means that first column is YEAR and so on. The output format that I like is to have all these columns in one to be able to plot Axis X like complete data, not only YEAR or DAY, etc.
Do you understand now? Thanks
Liviu
Liviu el 7 de Mzo. de 2012
YEAR MONTH DAY HOUR MINUTE SEC Temp1 Temp2
2011 11 01 00 00 00 30 40
2011 12 02 10 30 50 50 60
What I like is to be able to merge or to define the full time in order to plot it.
X Axis TIME
Y Axis Temp1
Y2 Axis Temp 2

Iniciar sesión para comentar.

 Respuesta aceptada

Dr. Seis
Dr. Seis el 7 de Mzo. de 2012

1 voto

DateNumber = datenum([Y, M, D, H, MN, S])
So...
X = datenum(data(:,1:6))-min(datenum(data(:,1:6))); % Normalized time
Y1 = data(:,7);
Y2 = data(:,8);
X is time in terms of fraction of a day - to get X in terms of seconds, multiply by 24*60*60

Más respuestas (1)

Liviu
Liviu el 8 de Mzo. de 2012

0 votos

clear all
DELIMITER = ' '; HEADERLINES = 43;
newData = importdata('DATA_20111022.TSFB', DELIMITER, HEADERLINES); vars = fieldnames(newData);
for i = 1:length(vars) assignin('base', vars{i}, newData.(vars{i})); end
clear vars DELIMITER HEADERLINES newData i textdata
X=datenum(data(:,1:6)); plot(X,data(:,8))

3 comentarios

Jan
Jan el 8 de Mzo. de 2012
Please format your code as explained in the "Markup help" link on this page.
There is no reason to remove all loaded functions from the memory using "clear all". It takes a lot of time to re-import the M-files afterwards. Perhaps you want "clear variables", but even this is useless here.
Dr. Seis
Dr. Seis el 8 de Mzo. de 2012
At what point do you assign the data to "data"?
Liviu
Liviu el 9 de Mzo. de 2012
Yes. This is wrong to clear the variables.
I assign the data to can save after.
How to find and copy from data1.dat to data3.dat The searching interval is found in data2.mat
I need to find in a database the time and to copy some of the rows in another files. INPUT1: data1.mat Col1=Time0 (datenum format "01-Mar-2000 15:45:17") Col2=Temp1 Col3=Temp2 INPUT2: data2.mat Col1=Time1 (datenum format "01-Mar-2000 15:45:17") Col2=Time2 (datenum format "01-Mar-2000 15:45:17")
INPUT3: data3.mat like INPUT1
Questions: 1. I want to find: the "Time1" from the "data2.mat" to fit with the "Time0" in the "data1.mat" 2. And find "Time2: from the "data2.mat" to fit with the "Time0" in the "data1.mat" 3. Copy from Time1 to Time2 from data1.mat in the data3.mat all the row.
2 comments

Iniciar sesión para comentar.

Categorías

Preguntada:

el 7 de Mzo. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by