Path: news.mathworks.com!not-for-mail
From: "zhang mian" <zhangmian0126@126.com>
Newsgroups: comp.soft-sys.matlab
Subject: Rs232 hardware communication,  fprintf
Date: Tue, 3 Nov 2009 05:28:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 5
Message-ID: <hcof12$gn8$1@fred.mathworks.com>
Reply-To: "zhang mian" <zhangmian0126@126.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257226083 17128 172.30.248.38 (3 Nov 2009 05:28:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 05:28:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1909003
Xref: news.mathworks.com comp.soft-sys.matlab:581968


Hi,
I am doing a hardware real time control through rs232 in M-file. The problem is when i put fprintf(serobj,'rat 1'),the motor will run at a speed 1ml/hr but if the speed is calculated by my program and represented by variable 'u1', i put it like fprintf(serobj,'rat u1')  the hardware will not response to it. Even it shows u1=12.25 or sth else, i put the fprintf(serobj,'rat u1'), the motor still run at a default speed 1ml/hr. I change it to 
fprintf(serobj,'rat 6'), the speed of the motor will change to 6ml/hr from 1ml/hr. 

The hardware technician said he was not familiar with Matlab but if the program is written in C, the function should be fprintf(serobj,'rat %f',u1). But it seems the Matlab doesn't accept this format. It only can be fprintf(serobj,format,variable), in this format the whole variable will become same format, number or character ect. Now i need the 'rat' in character format but the u1 in a float-point format, what can i do?