2016-03-06 111 views
-1

我绘制了一些变量和时间之间的关系。 时间位于矩阵中;部分如下:在Matlab中绘制时间的错误

> 19.997777777777774 
    19.998055555555560 
    19.998333333333338 
    19.998611111111117 
    19.998888888888892 

这是UTC时间(时间间隔:1小时,间隔:1秒)转换后带小数点的小时数。

我获得的身材似乎有错误: changes of latitude in time

它可以通过一些常见的原因造成的我没有注意到? 谢谢。

更新:

h=nmea/10000; 
h_int = floor(h); 
h_dec = h - h_int; 

m = h_dec * 100; 
m_int = floor(m); 
m_dec = m - m_int; 

s = m_dec * 100; 

time= h_int + m_int/60 + s/3600; 

参考NMEA:195955 195956 195957 195958 195959]

+0

您可以发布您用于绘图的代码吗? – Aziz

+0

plot(time,data1,time,data2) – reznik

+0

以及用于将时间转换为十进制小时的代码? – Aziz

回答

2

这是因为你所定义的分钟残留的方式。 如果您在更改分钟时运行代码,则会出现问题。在这里,您可以看到s的第三值“跳”(-a一轮分钟),导致跳在time

nmea=[195858 195859 195900 195901 195902] 
h=nmea/10000; 
h_int = floor(h); 
h_dec = h - h_int; 
m = h_dec * 100; 
m_int = floor(m); 
m_dec = m - m_int; 
s = m_dec * 100 
time= h_int + m_int/60 + s/3600 

s = 

    58.0000 59.0000 100.0000 1.0000 2.0000 


time = 

    19.9828 19.9831 19.9944 19.9836 19.9839 

对于较短的和正确的方法,你可以使用mod功能:

nmea=[195858 195859 195900 195901 195902]; 
m_int=(mod(nmea,10000)-mod(nmea,100))/100; 
s=mod(nmea,100); 
time= h_int + m_int/60 + s/3600 
time = 

    19.9828 19.9831 19.9833 19.9836 19.9839