Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Need help with code conversion from C++ to Matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
KSSV
le 24 Jan 2022
MATLAB should have some inbuilt function for this. Show us your input and what you are expecting?
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!