global ser; global sample_period; if (isempty(instrfind) ~= 1) o = instrfind; ser = o(1); delete(ser); %fclose(instrfind); %freeserial(instrfind); end ser=serial('COM7', 'BaudRate', 115200); fopen(ser); srate = 1/sample_period; fprintf(ser, 'START:%d\n',srate);