hi everyone

I am now working on connecting the MATLAB with Arduino. I tried two ways.

1. Using MATLAB GUI to design a interface

2. Using MATLAB M File to communicate with Arduino directly.

My problems are:

the same code in two ways

str = get(s1, 'TransferStatus');

if ~(strcmp(str, 'write') || strcmp(str, 'read&write'))

fwrite(s1,val,'uint8','async');

str1 = get(s1, 'TransferStatus');

end

My Questions are :

In MATLAB GUI it can run smothly, but in M File it needs

pause(1.5);

before fwrite().

1.if I do not put a pause, Arduino cannot receive data from Matlab successfully. and I can see a warning of time in MATLAB Command Window.

2.If I do not want to use the pause()in M file, can I use other ways to solve it?

Thanks a lot.