Coordinate interpolation with time

7 ビュー (過去 30 日間)
em_++
em_++ 2021 年 7 月 28 日
コメント済み: em_++ 2021 年 8 月 3 日
Hello!
I have a little question.
So I have 2 Data sets:
The first one consists of 12 coordinates(Lat, Long) taken every second hour (0 , 2am , 4 am....).
The second data set is a data set taken in 24 hours, but this time there is data every second.
Now i want to interpolate so i can do some plotting. I already managed to interpolate with this code (for 2 coordinates; I did this for all 12 coordinates and put them together in the end):
n = 7198 %Number of seconds in 2 hours
tripPath = zeros(n,2)
pf = polyfit(Lat(:,1) Lat(:,2)], [(Long(:,1) Long(:,2)] %Coordinates
x = linspace(Lat:,1),(Lat(:,2),n);
y = polyval(pf,x)
tripPath(:,1) = x
tripPath(:,2) = y
but now the big problem is, that every now and then there is a second missing so its not always exactly 7198 seconds (I dont know exactly where they are missing).
I was thinking that maybe i could check between for example 0 and 20000 (0 and 2 am and so on) how many array elements there are and put it in n.
I just cant get it work at all.
Thanks in advance!
  2 件のコメント
Star Strider
Star Strider 2021 年 7 月 28 日
I have no idea what the data actually are, however consider using a timetable and retime to do the interpolation.
.
em_++
em_++ 2021 年 7 月 31 日
It acutally doesnt matter what data it is as i just need the coordinates fitting to the seconds :)

サインインしてコメントする。

回答 (1 件)

Peter Perkins
Peter Perkins 2021 年 7 月 29 日
This line of code
pf = polyfit(Lat(:,1) Lat(:,2)], [(Long(:,1) Long(:,2)] %Coordinates
is not valid syntax for several reasons, but the important one is you don't say what order polynomial. I'm assuming that with two points, you're doing linear interpolation. If so, then SS is right, this is a one liner with a timetable and retime.
  2 件のコメント
em_++
em_++ 2021 年 7 月 31 日
Yes its a linear Interpolation
em_++
em_++ 2021 年 8 月 3 日
pf = polyfit([Lat(1,1) Lat(2,1)], [(Long(1,1) Long(2,1)],1) %Coordinates
should be the line

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by