Hi all,
I'm trying to send a double value (x) from Matlab to a 8bit microcontroller over the PC's serial port, but I dont't know how to make four 8 bit values out of my double. In the µC I can put the four 8bit values together to a 32bit float:
In C++ I would use a union:
union{
uint8_t j[4];
float f;
} u;
where i can selcet with u.f my float or with u.i[1] for example the first byte.
For example:
float 4xuint8
10.5 -> 0 0 40 65
and the reverse conversion
4xint8 float
0 0 40 65 -> 10.5
Can anyone give me an advice how to make this conversion in Matlab?
Regards,
condorrr
I'm trying to send a double value (x) from Matlab to a 8bit microcontroller over the PC's serial port, but I dont't know how to make four 8 bit values out of my double. In the µC I can put the four 8bit values together to a 32bit float:
In C++ I would use a union:
union{
uint8_t j[4];
float f;
} u;
where i can selcet with u.f my float or with u.i[1] for example the first byte.
For example:
float 4xuint8
10.5 -> 0 0 40 65
and the reverse conversion
4xint8 float
0 0 40 65 -> 10.5
Can anyone give me an advice how to make this conversion in Matlab?
Regards,
condorrr