Clear Filters
Clear Filters

Transferring data between two computers by mouse clicking a pushbutton using MATLAB GUI

2 views (last 30 days)
Hi I want to transfer data consitantly by mouse clicking a pushbutton in MATLAB GUI. Therefor I created a server (Server.m) and a client function (Verbraucher.m). The client function should open when the data is available and the server function has to open and close all secenonds, because in the same code is again a live-plot in a MATLAB GUI. But for some reasons the code doesn't work. Although I transfered data between two computers using the Server and Verbraucher file manually. For better understanding a added the functions and files.
  2 Comments
Geoff Hayes
Geoff Hayes on 24 Mar 2017
Maurice - can you clarify what you mean but the code doesn't work. Which portion of the code is failing? Transferring the data from one machine to another? Updating the live plot?
If you are observing any errors, please copy and paste the full error message to this question.
Maurice Rohracker
Maurice Rohracker on 26 Mar 2017
Using the "datentest"-GUI the data is transfered one time, after that this error message pop up in the command window of the Test_Server.m-file: Error using icinterface/fread (line 164) SIZE must be greater than 0.
Error in Server (line 14) data = fread(t1,elements,'double'); And after that a second error message pop up in the command window of the datentest.m-file, because the system is chrashed/ the Server.m doesn´t open any more I belive:Error using icinterface/fopen (line 83) Unsuccessful open: Connection refused: connect
Error in Verbraucher (line 6) fopen(server)
Error in datentest>last_pushbutton_Callback (line 91) Verbraucher(data,port)
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in datentest (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)datentest('last_pushbutton_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback.

Sign in to comment.

Accepted Answer

Anoop Somashekar
Anoop Somashekar on 31 Mar 2017
I ran the attached code and was able to send /receive the data between client and server. I was also able to recreate the error 'SIZE must be greater than 0' by passing an empty vector to the function Verbraucher i.e. Verbraucher([]). Since an empty vector is also a double, the BytesAvailable property at the server side will be greater than zero. You could add an extra check before performing an 'fread' as shown below:
if elements > 0
data = fread(reader,elements,'double');
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!