function varargout = UDP_sent(varargin)
% UDP_SENT M-file for UDP_sent.fig
% UDP_SENT, by itself, creates a new UDP_SENT or raises the existing
% singleton*.
%
% H = UDP_SENT returns the handle to a new UDP_SENT or the handle to
% the existing singleton*.
%
% UDP_SENT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UDP_SENT.M with the given input arguments.
%
% UDP_SENT('Property','Value',...) creates a new UDP_SENT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before UDP_sent_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to UDP_sent_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help UDP_sent
% Last Modified by GUIDE v2.5 10-Aug-2010 10:56:25 最后更新
% Begin initialization code - DO NOT EDIT 开始初始化代码
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...% 模式
'gui_OpeningFcn', @UDP_sent_OpeningFcn, ...
'gui_OutputFcn', @UDP_sent_OutputFcn, ...
'gui_LayoutFcn', [] , ... %布置功能
'gui_Callback', []); %GUI各个状态
if nargin && ischar(varargin{1}) % 输入参数数目若是字符串则为真,表示实际输入参量
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout %输出参数数目
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});%实际返回的参量
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT 结束初始化代码
% --- Executes just before UDP_sent is made visible.
function UDP_sent_OpeningFcn(hObject, eventdata, handles, varargin)%回调句柄,事件数据,句柄元素,实际输入参量(输入参数)
% This function has no output args, see OutputFcn.
% hObject handle to figure 回调句柄
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to UDP_sent (see VARARGIN)
% Choose default command line output for UDP_sent
handles.output = hObject; %输出参数为回调句柄
ipA = '10.0.3.32'; %A的IP地址和端口号
portA = 9090;
ipB = '10.0.3.32';%B的IP地址和端口号
portB = 9091;
handles.udpA = udp(ipB,portB,'LocalPort',portA);
set(handles.udpA,'OutputBufferSize',8192);%输出缓冲区容量,相当于设置窗口?
set(handles.udpA,'TimeOut',100);%接收和发送前超时时间
fopen(handles.udpA);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes UDP_sent wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = UDP_sent_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
for t = 1:15
x = sin(t);
set(handles.edit1,'String',x);
v1=str2double(get(handles.edit1,'string'));
w1(t)=v1;
fprintf(handles.udpA,v1);
pause(0.1);
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fclose(handles.udpA);
delete(handles.udpA);
clear ipA portA ipB portB
close();
Matlab UDP数据通讯工具箱用法
5星 · 超过95%的资源 需积分: 44 154 浏览量
2011-05-25
20:24:24
上传
评论 6
收藏 11KB RAR 举报
qiususan
- 粉丝: 1
- 资源: 1
最新资源
- python:利用matplotlib绘制直方图
- 基于matlab块匹配全景图像拼接系统代码12
- 基于matlab小波变换图像融合系统代码11
- 精雕3.5NC后置文件
- yolov8n-pose.pt 用 yolov8n-pose.onnx下载
- C++之STL的vector详解,包括初始化和各种函数:vector的初始化、数据的增删查改等
- stable-diffusion-webui-master
- openPLC-Editor C语言编程 在mp157 arm板上调用io等使用记录
- 无人机悬停时间计算软件.rar
- 主要讲解 mybatis中 实体层的属性与表的列不一致时如何处理? 可以采用将列重命名方法还可以采用resultMap 方式
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
前往页