this code is working with windows 7 and matlab.
%
instrhwinfo('serial');
ports = ans.AvailableSerialPorts
pause(1);
clc
display(['Scanning...']);
s1 = serial('COM4'); % define serial port ACM0 / USB0
s1.BaudRate=9600; % define baud rate
set(s1, 'terminator', 'LF'); % define the terminator for println CR or LF
fopen(s1);
try % use try catch to ensure fclose
% signal the arduino to start collection
w=fscanf(s1,'%s') % must define the input % d or %s, etc.
if (w=='A')
display(['Collecting data']);
fprintf(s1,'%s\n','A'); % establishContact just wants something to buffer
end
fclose(s1);
catch exception
fclose(s1);
delete(s1);
clear s1;
%freeserial;
end
so it seems the only problem are the usb ports. i have to define the right port to receive the data in matlab.