Info

此问题已关闭。 请重新打开它进行编辑或回答。

Need help with code conversion from C++ to Matlab

1 次查看(过去 30 天)
Hi, I am creating a function in matlab that will take GPS week number and second of the week as an input and return year, month, day, hh,mm,ss as its output.
I tried searching for a formula but I was't able to get it.
If someone can help me translate the following code, I will be very thankful for this act of kindness
Thank you please see the attached code snippet.
void gps2date(const gpstime_t *g, datetime_t *t)
{
// Convert Julian day number to calendar date
int c = (int)(7*g->week + floor(g->sec/86400.0)+2444245.0) + 1537;
int d = (int)((c-122.1)/365.25);
int e = 365*d + d/4;
int f = (int)((c-e)/30.6001);
t->d = c - e - (int)(30.6001*f);
t->m = f - 1 - 12*(f/14);
t->y = d - 4715 - ((7 + t->m)/10);
t->hh = ((int)(g->sec/3600.0))%24;
t->mm = ((int)(g->sec/60.0))%60;
t->sec = g->sec - 60.0*floor(g->sec/60.0);
return;
}
  2 个评论
KSSV
KSSV 2022-1-24
MATLAB should have some inbuilt function for this. Show us your input and what you are expecting?
Imtiaz nabi
Imtiaz nabi 2022-1-24
Actually I am creating a function that takes GPS week no and Second of the week as an input and return Year, Month, Day, Hour:Minutes:Seconds
I want to create a converter

回答(0 个)

此问题已关闭。

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by