Вот код, который я написал, чтобы это произошло, предложения приветствуются ...
- Затем установите приложение Matlab ...
%matlab instance #1, run on server
t = tcpip('0.0.0.0', 1234, 'NetworkRole', 'server');
fprintf('server is set up. \n\nwaiting for client to connect... ');
fopen(t);
fprintf('connected.\n')
fprintf('listening for user commands...\n\n');
while true
if t.BytesAvailable>0
data = fread(t,t.BytesAvailable);
if data==1
disp('1')
elseif size(data,1)>1 %parse several integers as strings
switch char(data')
case 'asdf'
disp('do asdf');
% >> at this point any input can be run using 'eval' << %
end
end
else
pause(2); %wait some seconds
end
end
%matlab instance #2, run on same server
%enable mobile app connection
connector on;
(connect then via mobile app, run following code from the mobile console)
try
t = tcpip('localhost',1234);
fclose(t)
fopen(t)
catch
fprintf('connection failed.\n');
return
end
fprintf('connection established.\n')
% send command to server
fwrite(t,'asdf')