Definition of Time

7 views (last 30 days)
Liviu
Liviu on 7 Mar 2012
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 Comments
Liviu
Liviu on 7 Mar 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 on 7 Mar 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

Sign in to comment.

Accepted Answer

Dr. Seis
Dr. Seis on 7 Mar 2012
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

More Answers (1)

Liviu
Liviu on 8 Mar 2012
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 Comments
Dr. Seis
Dr. Seis on 8 Mar 2012
At what point do you assign the data to "data"?
Liviu
Liviu on 9 Mar 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

Sign in to comment.

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!