refer to: http://www.mathworks.com/matlabcentral/fileexchange/21131-tcp-ip-socket-communications-in-matlab
And: http://cn.mathworks.com/help/instrument/creating-a-tcpip-object.html
Session 1: MATLAB Server
Accept a connection from any machine on port 30000.
t = tcpip('0.0.0.0', 30000, 'NetworkRole', 'server');
Open a connection. This will not return until a connection is received.
fopen(t);
Read the waveform and confirm it visually by plotting it.
data = fread(t, t.BytesAvailable); plot(data);
Session 2: MATLAB Client
This code is running on a second copy of MATLAB.
Create a waveform and visualize it.
data = sin(1:64); plot(data);
Create a client interface and open it.
t = tcpip('localhost', 30000, 'NetworkRole', 'client'); fopen(t)
Write the waveform to the server session.
fwrite(t, data)