From: Vinny on
I hate to admit that I spent most of my day dealing with this seemingly simple problem, but here it is:

I've got three columns of data form my instrument. I've got a column of data in the D/M/Y format, and a second column in the H/M/S format, and a third column with my actual data in it.

I want to get a line graph of all the points by the H/M/S, with the x-axis being the dates (as the plot makes no sence if the x axis is by the hour). I have not been able to concatenate the columns (in either excel or Matlab) to make a D/M/Y/H/M/S format matlab might understand.

So can anyone tell me how to either:

A- combine the columns into a single column that I can use as my x-axsis (and than just use datetick to pick what format I want my ticks to be in)

or

B- Plot using the H/M/S, and use the D/M/Y as my ticks
From: Jos on
"Vinny " <vmoriarty(a)csun.edu> wrote in message <h8rn7f$7ap$1(a)fred.mathworks.com>...
> I hate to admit that I spent most of my day dealing with this seemingly simple problem, but here it is:
>
> I've got three columns of data form my instrument. I've got a column of data in the D/M/Y format, and a second column in the H/M/S format, and a third column with my actual data in it.
>
> I want to get a line graph of all the points by the H/M/S, with the x-axis being the dates (as the plot makes no sence if the x axis is by the hour). I have not been able to concatenate the columns (in either excel or Matlab) to make a D/M/Y/H/M/S format matlab might understand.
>
> So can anyone tell me how to either:
>
> A- combine the columns into a single column that I can use as my x-axsis (and than just use datetick to pick what format I want my ticks to be in)
>
> or
>
> B- Plot using the H/M/S, and use the D/M/Y as my ticks

Can you give a small example of the input? Do you have strings, numbers?

Jos
From: Vinny on
"Jos " <#10584(a)fileexchange.com> wrote in message <h8soi9$3p5$1(a)fred.mathworks.com>...
> "Vinny " <vmoriarty(a)csun.edu> wrote in message <h8rn7f$7ap$1(a)fred.mathworks.com>...
> > I hate to admit that I spent most of my day dealing with this seemingly simple problem, but here it is:
> >
> > I've got three columns of data form my instrument. I've got a column of data in the D/M/Y format, and a second column in the H/M/S format, and a third column with my actual data in it.
> >
> > I want to get a line graph of all the points by the H/M/S, with the x-axis being the dates (as the plot makes no sence if the x axis is by the hour). I have not been able to concatenate the columns (in either excel or Matlab) to make a D/M/Y/H/M/S format matlab might understand.
> >
> > So can anyone tell me how to either:
> >
> > A- combine the columns into a single column that I can use as my x-axsis (and than just use datetick to pick what format I want my ticks to be in)
> >


> > or
> >
> > B- Plot using the H/M/S, and use the D/M/Y as my ticks
>
> Can you give a small example of the input? Do you have strings, numbers?
>
> Jos

Thanks for the reply- here is a small subset of what is given to me by my instrument

6/5/2009 11:50:12 PM 0
6/5/2009 11:50:14 PM 0
6/5/2009 11:50:16 PM 0
6/5/2009 11:50:18 PM 0
6/6/2009 12:00:00 AM 0
6/6/2009 12:00:02 AM 0
6/6/2009 12:00:04 AM 0
6/6/2009 12:00:06 AM 0
6/6/2009 12:00:08 AM 0
6/6/2009 12:00:10 AM 0
6/6/2009 12:00:12 AM 0.09
6/6/2009 12:00:14 AM 0
6/6/2009 12:00:16 AM 0.09
6/6/2009 12:00:18 AM 0
6/6/2009 12:10:00 AM 0
6/6/2009 12:10:02 AM 0.09
6/6/2009 12:10:04 AM 0
6/6/2009 12:10:06 AM 0.09
6/6/2009 12:10:08 AM 0.09
6/6/2009 12:10:10 AM 0.09
6/6/2009 12:10:12 AM 0.09
6/6/2009 12:10:14 AM 0
6/6/2009 12:10:16 AM 0
6/6/2009 12:10:18 AM 0
6/6/2009 12:20:00 AM 0
6/6/2009 12:20:02 AM 0
6/6/2009 12:20:04 AM 0
6/6/2009 12:20:06 AM 0
From: dpb on
Vinny wrote:
....
>>> ... I have not been able to concatenate the
>>> columns (in either excel or Matlab) to make a D/M/Y/H/M/S format
>>> matlab might understand.
>>>
>>> So can anyone tell me how to either:
>>>
>>> A- combine the columns into a single column that I can use as my
>>> x-axsis (and than just use datetick to pick what format I want my
>>> ticks to be in)
....

No problem in getting a ML datenum that (I think works w/ plot axes???)

>> s1='6/5/2009 11:50:12 AM';
>> s2='6/5/2009 11:50:12 PM';
>> s=strvcat(s1,s2)
s =
6/5/2009 11:50:12 AM
6/5/2009 11:50:12 PM
>> d=datenum(s)
d =
1.0e+005 *
7.33929493194444
7.33929993194444
>> d(2)-d(1)
ans =
0.50000000000000
>> % note the 0.5 day difference of down to AM/PM is significant and
interpreted by datenum()

Just read the data into a string array w/ '%s %s' and all should be
well... :)

--

From: dpb on
dpb wrote:
> Vinny wrote:
> ...
>>>> ... I have not been able to concatenate the
>>>> columns (in either excel or Matlab) to make a D/M/Y/H/M/S format
>>>> matlab might understand.
>>>>
>>>> So can anyone tell me how to either:
>>>>
>>>> A- combine the columns into a single column that I can use as my
>>>> x-axsis (and than just use datetick to pick what format I want my
>>>> ticks to be in)
> ...
>
> No problem in getting a ML datenum that (I think works w/ plot axes???)
>
> >> s1='6/5/2009 11:50:12 AM';
> >> s2='6/5/2009 11:50:12 PM';
> >> s=strvcat(s1,s2)
> s =
> 6/5/2009 11:50:12 AM
> 6/5/2009 11:50:12 PM
> >> d=datenum(s)
> d =
> 1.0e+005 *
> 7.33929493194444
> 7.33929993194444
> >> d(2)-d(1)
> ans =
> 0.50000000000000
> >> % note the 0.5 day difference of down to AM/PM is significant and
> interpreted by datenum()
>
> Just read the data into a string array w/ '%s %s' and all should be
> well... :)

OK, I had a little more time...I've not done much w/ datenum (like
nothing :) nor much more than rudimentary w/ strings in ML--all my time
series are higher speed where TOD has no real bearing) so there may be
some more straightforward ways or there may be newer functions that
handle some of it (particularly the concatenation part as I also have a
fairly old version since retired some time ago)...

Anyway, I copied your previous data to file 'date.dat'

[d,t,am,x] = textdata('date.dat', '%s %s %s %f'); % date time ampm data
s % look at the date strings
dn=datenum(s); % convert to datenums

I assume from this point you should be able to plot and fiddle with tick
labels to get a suitable graph.

Looking in the online documentation it doesn't seem that plot() yet does
have an option to automagically generate the time labels; perhaps
there's something in the user exchange that would help.

--