1

I am trying to communicate with a serial port trought matlab. This is my code:

delete (instrfindall)
clear all
close all
clc; 

s=serial('COM4');
set(s,'BaudRate',4800);
set(s,'DataBits',8);
set(s, 'Parity','none');
set(s,'StopBits',1);
set(s, 'FlowControl','none');
set(s,'Terminator','CR');
set(s,'TimeOut',5000); 

fopen(s)
%Move the probe radial
fprintf(s,'%s','RADIAL=100');

out=fgets(s);

fclose (s)
delete (s)
clear (s)

But i cannot make the serial port to answer me. Can you help me? Is this code right?

Best regards,

  • The baud rate seems a bit low. Have you tried higher rates, ex: 38400? – Igor Stoppa Mar 21 '16 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.