Thread Subject: tcpip / udp under GUI

Subject: tcpip / udp under GUI

From: ahmad azizul azizul

Date: 23 Nov, 2009 08:24:04

Message: 1 of 2

Hi,
I am new with MATLAB and I found a way to transfer data between 2 computers using udp at

http://www.mathworks.com/support/solutions/en/data/1-OUCYT/index.html?solution=1-OUCYT

I tried the code at the command window and it is working.
However, when I tried to put it into my GUI, the code does not work and I don't know how to correct it.

example of my send_pushbutton
% --- Executes on button press in send_pushbutton.
function send_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to send_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = get(handles.answer_statictext,'String')
a2= eval(a)
b = get(handles.Input1_editText,'String'), %plaintext

if a2==0 %% actually if a=nothing
    d=b
else
    d=a
end

%% Define computer-specific variables
ipA = '1xxx'; portA = 3034; % Modify these values to be those of your first computer.
ipB = '1xxx'; portB = 3035; % Modify these values to be those of your second computer.

%% Create UDP Object
udpA = udp(ipB,portB,'LocalPort',portA)

%% Connect to UDP Object
fopen(udpA)

fprintf(udpA,d)

and example of my receive_pushbutton
% --- Executes on button press in RECEIVE_pushbutton.
function RECEIVE_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to RECEIVE_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% Define computer-specific variables
% Modify these values to be those of your first computer:
ipA = '1xxxx; portA = 3034;
% Modify these values to be those of your second computer:
ipB = '1xxxx'; portB = 3035;

%% Create UDP Object
udpB = udp(ipA,portA,'LocalPort',portB);

%% Connect to UDP Object
fopen(udpB)

fscanf(udpB)

set(handles.answer_statictext,'String',udpB)


Is my code correct? Is there anything wrong with it?
And what should I do if I want to use tcpip to communicate between the 2 computers?
Please help me, I really appreciate your help.

Subject: tcpip / udp under GUI

From: ahmad azizul azizul

Date: 24 Nov, 2009 01:25:21

Message: 2 of 2

Help anyone?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui ahmad azizul azizul 23 Nov, 2009 03:29:05
udp ahmad azizul azizul 23 Nov, 2009 03:29:05
tcpip ahmad azizul azizul 23 Nov, 2009 03:29:04
rssFeed for this Thread

Contact us at files@mathworks.com