Beginners Question - diagram date / values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Beginners Question - diagram date / values

Martin Wagner
Hi @all,

I'm trying to create a simple time / values X-Y diagram. However, I'm
having a weird resolution problem on the X axis. 
For some reason, multiple y values are assinged to one sinlge X time
value (see https://ibb.co/eZJYxn).
This is the same data in libre office: https://ibb.co/iLYcOS .

When I check the time values, all of them are the same values.

Any ideas what I'm doing wrong?

Thanks for your help!



This is the csv source data:

Time,Temperature
27.02.2018 17:10:56,19.99
27.02.2018 17:11:57,19.91
27.02.2018 17:12:58,20.01
27.02.2018 17:13:59,19.98
27.02.2018 17:15:00,20.15
27.02.2018 17:16:01,20.20
27.02.2018 17:17:02,20.14
... many more days

and this is the code I tried:

fd = fopen('file.csv')

a = textscan(fd, '%s %f', 'Delimiter', ',', 'HeaderLines', 1)

a
a = 
{
  [1,1] = 
  {
    [1,1] = 27.02.2018 17:10:56
    [2,1] = 27.02.2018 17:11:57
    [3,1] = 27.02.2018 17:12:58
    [4,1] = 27.02.2018 17:13:59
    [5,1] = 27.02.2018 17:15:00
    [6,1] = 27.02.2018 17:16:01
    [7,1] = 27.02.2018 17:17:02
  }
  [1,2] =

     19.990
     19.910
     20.010
     19.980
     20.150
     20.200
     20.140

}

a{1} = datenum(a{1},'dd.mm.yyyy HH:MM:SS');
a
a = 
{
  [1,1] =

     7.3712e+05
     7.3712e+05
     7.3712e+05
     7.3712e+05
     7.3712e+05
     7.3712e+05
     7.3712e+05

  [1,2] =

     19.990
     19.910
     20.010
     19.980
     20.150
     20.200
     20.140

}

plot(a{1},a{2})




-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Question - diagram date / values

siko1056
Martin Wagner wrote

> Hi @all,
>
> I'm trying to create a simple time / values X-Y diagram. However, I'm
> having a weird resolution problem on the X axis. 
> For some reason, multiple y values are assinged to one sinlge X time
> value (see https://ibb.co/eZJYxn).
> This is the same data in libre office: https://ibb.co/iLYcOS .
>
> When I check the time values, all of them are the same values.
>
> Any ideas what I'm doing wrong?
>
> Thanks for your help!
>
> [ ... snip ... ]
>
> a{1} = datenum(a{1},'dd.mm.yyyy HH:MM:SS');
> a
> a = 
> {
>   [1,1] =
>
>      7.3712e+05
>      7.3712e+05
>      7.3712e+05
>      7.3712e+05
>      7.3712e+05
>      7.3712e+05
>      7.3712e+05
>
> [snip]

My guess is, that your x-axis values are badly scaled.  Your values are
about 10^5, but the differences in the numbers is about 10^(-2), likely to
exceed the tolerance of single precision.  Maybe try something like below:

```
blub = ["Time,Temperature\n" ...
"27.02.2018 17:10:56,19.99\n" ...
"27.02.2018 17:11:57,19.91\n" ...
"27.02.2018 17:12:58,20.01\n" ...
"27.02.2018 17:13:59,19.98\n" ...
"27.02.2018 17:15:00,20.15\n" ...
"27.02.2018 17:16:01,20.20\n" ...
"27.02.2018 17:17:02,20.14"];

a = textscan (blub, '%s %f', 'Delimiter', ',', 'HeaderLines', 1);
a{1} = datenum (a{1}, 'dd.mm.yyyy HH:MM:SS');
x = a{1};
y = a{2};
figure ();
plot (x, y)
figure ();
plot (x - x(1), y)
```

HTH,
Kai



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------