Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
datenum and data problem

Subject: datenum and data problem

From: enviro

Date: 15 Mar, 2010 06:53:27

Message: 1 of 6

Dear All;
Please see input and output(what I wish to get).Please
see also what I tried so far. But thers seems to be a problem. Could someone please help me?
Thanks in advance

---------------------------------------------
[m,~] = size(input);
 output=datenum(input(:,1),'dd/mm/yyyy HH:MM:SS');
    for i=1:m;
        for j=i+1;
break
            if output(j,1)<output(i,1);
                output(j,1)=datenum(input(j,1),'mm/dd/yyyy HH:MM:SS');
            end
        end
    end
 output2 = datestr(output,'dd/mm/yyyy HH:MM:SS');
----------------------------------------------

input={
'30/11/2006 06:00:00'
'30/11/2006 07:00:00'
'30/11/2006 08:00:00'
'30/11/2006 09:00:00'
'30/11/2006 10:00:00'
'30/11/2006 11:00:00'
'12/01/2006 00:00:00'
'12/01/2006 01:00:00'
'12/01/2006 02:00:00'
'12/01/2006 03:00:00'
'12/01/2006 04:00:00'
'12/01/2006 05:00:00'
'12/01/2006 06:00:00'
'12/01/2006 07:00:00'
'12/01/2006 08:00:00'
'12/01/2006 09:00:00'
'12/01/2006 10:00:00'
'12/01/2006 11:00:00'};


output={
'30/11/2006 06:00:00'
'30/11/2006 07:00:00'
'30/11/2006 08:00:00'
'30/11/2006 09:00:00'
'30/11/2006 10:00:00'
'30/11/2006 11:00:00'
'01/12/2006 00:00:00'
'01/12/2006 12:00:00'
'01/12/2006 02:00:00'
'01/12/2006 03:00:00'
'01/12/2006 04:00:00'
'01/12/2006 05:00:00'
'01/12/2006 06:00:00'
'01/12/2006 07:00:00'
'01/12/2006 08:00:00'
'01/12/2006 09:00:00'
'01/12/2006 10:00:00'
'01/12/2006 11:00:00'};

Subject: datenum and data problem

From: enviro

Date: 15 Mar, 2010 09:26:42

Message: 2 of 6

Any suggestions?

Subject: datenum and data problem

From: ade77

Date: 15 Mar, 2010 18:44:08

Message: 3 of 6

enviro <farhadnejadkoorki@yahoo.co.uk> wrote in message <809613694.382032.1268645232157.JavaMail.root@gallium.mathforum.org>...
> Any suggestions?

Envivo,

Can you just post the input and expected output(the correct output you want) of your problem, and forget about your code for a moment. it is confusing what you are doing.

It seems the your data is changing from UK regional time to US regional time which is common with some logger programs.

Subject: datenum and data problem

From: ade77

Date: 15 Mar, 2010 19:26:24

Message: 4 of 6


> Please see input and output(what I wish to get).Please
>
> input={
> '30/11/2006 06:00:00'
> '30/11/2006 07:00:00'
> '30/11/2006 08:00:00'
> '30/11/2006 09:00:00'
> '30/11/2006 10:00:00'
> '30/11/2006 11:00:00'
> '12/01/2006 00:00:00'
> '12/01/2006 01:00:00'
> '12/01/2006 02:00:00'
> '12/01/2006 03:00:00'
> '12/01/2006 04:00:00'
> '12/01/2006 05:00:00'
> '12/01/2006 06:00:00'
> '12/01/2006 07:00:00'
> '12/01/2006 08:00:00'
> '12/01/2006 09:00:00'
> '12/01/2006 10:00:00'
> '12/01/2006 11:00:00'};
>
>
> output={
> '30/11/2006 06:00:00'
> '30/11/2006 07:00:00'
> '30/11/2006 08:00:00'
> '30/11/2006 09:00:00'
> '30/11/2006 10:00:00'
> '30/11/2006 11:00:00'
> '01/12/2006 00:00:00'
> '01/12/2006 12:00:00'
> '01/12/2006 02:00:00'
> '01/12/2006 03:00:00'
> '01/12/2006 04:00:00'
> '01/12/2006 05:00:00'
> '01/12/2006 06:00:00'
> '01/12/2006 07:00:00'
> '01/12/2006 08:00:00'
> '01/12/2006 09:00:00'
> '01/12/2006 10:00:00'
> '01/12/2006 11:00:00'};


my mistake, I see you already post the input and expected output. Can you explain the logic here:

input:
'12/01/2006 00:00:00'
'12/01/2006 01:00:00'
'12/01/2006 02:00:00'
'12/01/2006 03:00:00'

output:
'01/12/2006 00:00:00'
'01/12/2006 12:00:00'
'01/12/2006 02:00:00'
'01/12/2006 03:00:00'

obviously,the months and days are switched, but how about the hour, minute and day, what is the relationship?
 input{'12/01/2006 01:00:00'} and output{'01/12/2006 12:00:00'} is the only discrepancy I can not figure out.

Subject: datenum and data problem

From: enviro

Date: 16 Mar, 2010 06:31:35

Message: 5 of 6

hour, minute, seconds are constant. But the month and day have beed replaced for instance from row 7 and I want to maket them identical to rows 1 to 7. Please see input and the output I wish to get.

Input={
'30/11/2006 18:00:00'
'30/11/2006 19:00:00'
'30/11/2006 20:00:00'
'30/11/2006 21:00:00'
'30/11/2006 22:00:00'
'30/11/2006 23:00:00'
'12/01/2006 00:00:00'
'12/01/2006 01:00:00'
'12/01/2006 02:00:00'
'12/01/2006 03:00:00'
'12/01/2006 04:00:00'
'12/01/2006 05:00:00'
'12/01/2006 06:00:00'
'12/01/2006 07:00:00'
'12/01/2006 08:00:00'
'12/01/2006 09:00:00'
'12/01/2006 10:00:00'
'12/01/2006 11:00:00'
};


output={
'30/11/2006 18:00:00'
'30/11/2006 19:00:00'
'30/11/2006 20:00:00'
'30/11/2006 21:00:00'
'30/11/2006 22:00:00'
'30/11/2006 23:00:00'
'01/12/2006 00:00:00'
'01/12/2006 01:00:00'
'01/12/2006 02:00:00'
'01/12/2006 03:00:00'
'01/12/2006 04:00:00'
'01/12/2006 05:00:00'
'01/12/2006 06:00:00'
'01/12/2006 07:00:00'
'01/12/2006 08:00:00'
'01/12/2006 09:00:00'
'01/12/2006 10:00:00'
'01/12/2006 11:00:00'
};

Subject: datenum and data problem

From: enviro

Date: 18 Apr, 2010 08:23:00

Message: 6 of 6

So is there a way to find dates in the US format and convert them to the European one in a cell array?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us