Arduino, Firmata, and Matlab.

I’ve spent an entire day trying to get Firmata to talk to Matlab, but I’m not having very much luck. I can’t figure out how to get Matlab to read or write to the device. I can speak to the device with Hyperterminal and also with Processing, so it is working properly. Here is my Matlab code so far:

% Matlab to Firmata

instrreset; %Let go of the serial port if something is holding it open

% Get a handle to the serial port
s = serial('COM9');

% Set the parameters for connecting with Firmata
set(s,'BaudRate', 57600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none');

% Open the serial port connection
fopen(s);
pause(4);% wait for the arduino to reboot

% Send a command
fprintf(s, '%x', 249) %same as hex 9F to return firmware number
fprintf(1,'%x', 249) %duplicate the command to print to the command line

% Get the firmware reply:
out = fscanf(s)
%out = fread(s)

fclose(s); %close up and clean up
delete(s)
clear s

Basically, to get Firmata to work with Matlab it looks like we need a working MIDI implementation in Matlab. As it is, the program times out or returns “249,0,1” or “ù”. Any suggestions would be very welcome.