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);

Answers (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.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Asked:

on 10 Sep 2012

Community Treasure Hunt

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

Start Hunting!