Hi Walter,
I can reproduce the behavior on a system with a serial port. The documentation (mostly the syntax section) of serial/fprintf indicates that the data to be sent to the device needs to be a string. However in the example you mentioned the format parameter includes different non-character item specifiers (specifically %d - which is signed decimal notation). When I opened that function, I noticed that serial/fprintf function accepts only 'string' and 'double' data types. Hence the error while trying to pass an array which is of type 'uint8'. If you have not tried already, you can try these workarounds:
1. Cast the uint8 value as double:
>> fprintf(s, '*%d', double(data(:))) ;
2. Use sprintf to build the 'cmd' string which is then passed as an argument to serial/fprintf function:
>> str = sprintf('%u\n',data);
>> fprintf(s, str);
3 Use fwrite function which writes binary data (could be uint8) to the device. >> fwrite(s, data, 'uint8');
I work with MathWorks and would communicate the ambiguity in the documentation of the function and the possibility of allowing other data types (such as 'uint8') as accepted arguments, to the respective development teams.
-Nalini
Best Answer