Serial communication between Matlab and PIC

how can sent floating number from matlab to PIC such as 1.35 , 1.06, 1.85 ?
when i sent 1.35 received in PIC 1 when i sent 1.85 received in PIC 2
the code that used in Matlab
u=1.35; fwrite(s,u);

回答(1 个)

precision controls the number of bits written for each value and the interpretation of those bits as integer, floating-point, or character values. If precision is not specified, uchar (an 8-bit unsigned character) is used. The supported values for precision are listed below in Tips.
Thus you need to adjust the precision argument.
However, you need to research how PIC expects floating point values to be represented, and you need to represent them the same way.

类别

在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息

提问:

2012-9-10

Community Treasure Hunt

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

Start Hunting!

Translated by