Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Need help with code conversion from C++ to Matlab

1 visualizzazione (ultimi 30 giorni)
Imtiaz nabi
Imtiaz nabi il 24 Gen 2022
Chiuso: John D'Errico il 24 Gen 2022
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 Commenti
KSSV
KSSV il 24 Gen 2022
MATLAB should have some inbuilt function for this. Show us your input and what you are expecting?
Imtiaz nabi
Imtiaz nabi il 24 Gen 2022
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

Risposte (0)

Questa domanda è chiusa.

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by