help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: plotting time series in Octave


From: financial engineer
Subject: FW: plotting time series in Octave
Date: Sun, 25 Mar 2012 22:01:16 -0400

my message bounced back as undeliverable...so, resending...


From: address@hidden
To: address@hidden
CC: address@hidden
Subject: RE: plotting time series in Octave
Date: Sun, 25 Mar 2012 21:59:48 -0400



> Subject: Re: plotting time series in Octave
> From: address@hidden
> Date: Sun, 25 Mar 2012 17:59:54 -0400
> CC: address@hidden
> To: address@hidden
>
>
> On Mar 25, 2012, at 5:49 PM, financial engineer wrote:
>
> > I have the following data and I am trying to plot the time series and an overlay of signals on it
> >
> > 2011-12-06 02:15:00," 3.113830e-01"," 1.909586e+02","U","8575.000"," 0.000"," 0.000"," 0","0.887775615"
> > 2011-12-06 02:16:00," 2.630128e-01"," 1.848320e+02","U","8575.000"," 0.000"," 0.000"," 0","0.891741773"
> > 2011-12-06 02:17:00," 2.194390e-01"," 1.784746e+02","B","8575.000","8554.142","8556.332","8550","0.892192117"
> > 2011-12-06 02:18:00," 1.750296e-01"," 1.727000e+02","B","8575.000","8554.287","8556.518","8550","0.894445120"
> > 2011-12-06 02:19:00,"-2.392036e+00"," 1.558317e+02","U","8580.000"," 0.000"," 0.000"," 0","0.898210621"
> > 2011-12-06 02:20:00,"-3.538674e+00"," 3.513018e+02","U","8580.000"," 0.000"," 0.000"," 0","0.898689659"
> > 2011-12-06 02:21:00,"-5.469638e+00"," 6.806506e+02","U","8582.500"," 0.000"," 0.000"," 0","0.901698147"
> >
> > I have converted the data into a matrix:
> > C=csv2cell("test.csv",",")
> >
> > and then ran the following command:
> > octave-3.2.4:23> C{3:4,1:9}
> > ans = 2011-12-06 02:17:00
> > ans = 2011-12-06 02:18:00
> > ans = 0.21944
> > ans = 0.17503
> > ans = 178.47
> > ans = 172.70
> > ans = B
> > ans = B
> > ans = 8575
> > ans = 8575
> > ans = 8554.1
> > ans = 8554.3
> > ans = 8556.3
> > ans = 8556.5
> > ans = 8550
> > ans = 8550
> > ans = 0.89219
> > ans = 0.89445
> >
> > I tried to plot using the following command:
> > octave-3.2.4:22> plot(C{3:4,5},C{3:4,6})
> >
> > and I get a blank graph....obviously I am doing something silly....
> >
> > my ultimate goal is:
> > 1. plot a time series with the first column as my x-axis and the 5th column as my y-axis
> > 2. overlay points on the time series graph (at the price) to indicate a B whenever a B shows up in the 4th column
> >
> > Can someone please help me make the first correct step so I can move to the second step. Thanks!
>
> I haven't tested this, but your plot command is equivalent to ...
>
> plot (C{3,5}, C{4,5}, C{3,6}, C{4,6})
>
> I assume you want ...
>
> plot ([C{3,5}, C{4,5}], [C{3,6}, C{4,6}])
>
> You can do that by ...
>
> plot ([C{3:4,5}], [C{3:4,6}])
>
> Ben
>

so, now I am trying to plot a time series of the date-time (column 1) vs. column 5,
when I try to run plot([C{3:4,1}],[C{3:4,5}])

I get the following error:
error: plot: no data to plot
error: called from:
error:   /usr/share/octave/3.2.4/m/plot/__plt__.m at line 90, column 4
error:   /usr/share/octave/3.2.4/m/plot/plot.m at line 186, column 5
octave-3.2.4:25>
gnuplot> plot "-";
              ^
         line 6: warning: Skipping data file with no valid points


so, I used a sample line to convert the date-time as follows,
C{1}
ans = 2011-12-06 01:38:00
octave-3.2.4:28> datestring=sprintf('%s',C{1})
datestring = 2011-12-06 01:38:00

and tried to see if plot works:
plot(datestring,C{40,5})
error: plot: no data to plot
error: called from:
error:   /usr/share/octave/3.2.4/m/plot/__plt__.m at line 90, column 4
error:   /usr/share/octave/3.2.4/m/plot/plot.m at line 186, column 5

gnuplot> plot "-";
              ^
         line 10: warning: Skipping data file with no valid points

so, I wrote the below, but obviously I am not doing it right....

octave-3.2.4:35> strptime(datestring,'%Y-%m-%d %T')
ans =
{
  usec = 0
  sec = 0
  min =  38
  hour =  1
  mday =  6
  mon =  11
  year =  111
  wday =  2
  yday =  339
  isdst = 0
  zone = EST
}

Is there a way I can do a simple 2d plot of the date-time(aggregated by minutes or hours) and C{5}...can someone please point me in the correct direction...thanks, Bobby

reply via email to

[Prev in Thread] Current Thread [Next in Thread]