Re: 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
|

Re: Beginners Question - diagram date / values

siko1056

On Sat, Mar 31, 2018 at 8:42 PM Martin Wagner <[hidden email]> wrote:
Thanks, this works so far. But now X axis is in Days from the beginning
of the recording. How do I get the original times in X axis?

 
Please keep the help mailing list in the CC.  This way others may profit from our dialogue.  The following should bring you the original times to the X axis:

```
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 - x(1), y)
set (gca (), "xticklabel", datestr(x,'dd.mm.yyyy HH:MM:SS'));
```

Unfortunately the datetick-Function [1] does not behave well here, because of the aforementioned bad scaling of the xtick data, therefore this ugly workaround seems necessary.

HTH,
Kai



Reply | Threaded
Open this post in threaded view
|

Re: Beginners Question - diagram date / values

Martin Wagner
Thanks!

There is still something wrong. When I execute the line

> set (gca (), "xticklabel", datestr(x,'dd.mm.yyyy HH:MM:SS'));

I get dates starting at the right point, but only increasing a few
minutes for a dataset of three weeks (see https://ibb.co/iiKgC7). Any
ideas what is going wrong?