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

Walter Roberson
Walter Roberson 2012년 9월 10일
편집: Walter Roberson 2012년 9월 10일

0 개 추천

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