[Scilab-users] Converting UT to Standard Time
Florian Winter
flotschos at gmail.com
Wed Dec 9 18:37:37 CET 2015
Hi,
I have a problem. I get data about the time from a file in UT. That means I
get the number of seconds elapsed on the day instead of a "normal" time
(e.g. 63602 actually means 17:40:02)
I'm trying to plot some values with this time but to make it more readable
I would like to use "17:40:02" for the ticks on the x-axis instead of the
seconds,
so I wrote a function to convert the seconds to a string.
If I don't change the ticks to the custom strings it automatically only
shows 7 ticks but if I change it like I did, it shows the ticks for every
single value I use and the whole thing becomes sort of unreadable.
Is there a possibility to convert the time differently or can I somehow
limit the number of ticks that should be drawn?
///////////////////////////////////////////////////////////////////////
time = [63602,63602.05,63603,63603.5,63604,63606]
values = [1,2,3,4,5,7]
function convertedtime = timestring(UT) //converts UT
h=int(UT/3600);
UT=UT-h*3600;
m=int(UT/60);
UT=UT-m*60;
if UT < 10 then
convertedtime = string(h) + ":" + string(m) + ":0" + string(UT);
else
convertedtime = string(h) + ":" + string(m) + ":" +string(UT);
end
endfunction
newtime = timestring(time);
plot(time,values);
a=gca();
ticks = a.x_ticks
ticks.labels=newtime
ticks.locations=time
a.x_ticks=ticks
////////////////////////////////////////////////////////////
Regards,
Flotschos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20151209/566d812e/attachment.htm>
More information about the users
mailing list