GPS Time conversion from uint8 to decimal
Mostra commenti meno recenti
I have the following GPS time in decimal as follows [65 31 163 67 100 90 28 172] and the data type is uint8. I need to write a matlab function as a block in Simulink to convert the time to the value 518352.848. Currently, the only way is to convert the data to hex and then back to decimal. As simulink does not accept char type, how can i do this conversion without going through the hex conversion?
Risposte (2)
James Tursa
il 29 Lug 2016
Can you use either of these?
>> u = uint8([65 31 163 67 100 90 28 172])
u =
65 31 163 67 100 90 28 172
>> typecast(u(8:-1:1),'double')
ans =
5.183528480000000e+005
>> swapbytes(typecast(u,'double'))
ans =
5.183528480000000e+005
1 Commento
Kelvin Wong
il 29 Lug 2016
Walter Roberson
il 29 Lug 2016
0 voti
Use the same kind of steps that I showed you in http://www.mathworks.com/matlabcentral/answers/297415-convert-decimal-to-ieee-754-32-bit-single-precision-floating-point#answer_229990 -- in particular, make sure you initialize the output to be a scalar so that the output of the typecast returns a scalar.
Categorie
Scopri di più su Unit Conversions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


