[Scilab-users] Converting UT to Standard Time
Pablo Fonovich
pablo_f_7 at hotmail.com
Wed Dec 9 20:12:09 CET 2015
Hi:
You may also define a vector with any label regardless your data, and the data of a particular point could be visually interpolated by the reader with a grid, just like excell does... I'm not sure if i'm clear enough... i'll send you an example
time = [63602,63602.05,63602.09,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
timeTics=time(1):0.8:time($)
newtime = timestring(timeTics);
plot(time,values);
a=gca();
ticks = a.x_ticks
ticks.labels=newtime
ticks.locations=timeTics
a.x_ticks=ticks
Of course, the label does not represent actual data you read from a file or something, they would just be text labels to let you read the plot... with this approach you can define the distance between each tic easily
From: pablo_f_7 at hotmail.com
To: users at lists.scilab.org
Date: Wed, 9 Dec 2015 16:00:32 -0300
Subject: Re: [Scilab-users] Converting UT to Standard Time
Hi:
First of all i want to ask you if time = [63602,63602.05,63603,63603.5,63604,63606] is correct. As you may notice, the first two values are too near... so in the plot the tics appear overlapped... if you use time = [63602,63602.5,63603,63603.5,63604,63606] the plot's tics become clearer...
The second question is how near this tics are supposed to be in the worst case? for example, if your time conssists of values sepparated about 0.05, you could create a new vector containing the positions of the tics, that exclude too near values... I mean:
time = [63602,63602.05,63602.09,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
timeTics=time(1)
for i=1:length(time)
if(abs(timeTics($)-time(i))>=0.5)
timeTics=[timeTics;time(i)]
end
end
newtime = timestring(timeTics);
plot(time,values);
a=gca();
ticks = a.x_ticks
ticks.labels=newtime
ticks.locations=timeTics
a.x_ticks=ticks
This may be non optimall solution, but may work
Date: Wed, 9 Dec 2015 18:37:37 +0100
From: flotschos at gmail.com
To: users at lists.scilab.org
Subject: [Scilab-users] Converting UT to Standard Time
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); endendfunction
newtime = timestring(time);
plot(time,values);a=gca();ticks = a.x_ticksticks.labels=newtimeticks.locations=timea.x_ticks=ticks
////////////////////////////////////////////////////////////
Regards,Flotschos
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20151209/5c1d8735/attachment.htm>
More information about the users
mailing list