基本信息
源码名称:matlab tcpip通信
源码大小:0.20M
文件格式:.zip
开发语言:MATLAB
更新时间:2019-07-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 5 元×
微信扫码支付:5 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
function udp_plotter_demo(lport)
% UDP_PLOTTER_DEMO - Opens a figure and starts to listen for UDP packages to plot.
% Syntax:
% UDP_PLOTTER_DEMO
% or
% UDP_PLOTTER_DEMO localport
%
% This script is a demo that listen for a UDP packet (default port 3333) and
% uses PLOT to dplay the sequence of doubles in the packet.
%
% (C) 2002 Peter Rydes鋞er
% Add default argument
if nargin<1, lport=3333; end
% Write help message
disp ' ';
disp 'To send packages to be plotted use e.g.';
disp(sprintf(' Use: udp_send_demo sin(0:0.1:6) '));
disp 'or';
disp(sprintf(' Use: udp_send_demo sin(0:0.1:6) HOSTNAME'));
disp ' ';
disp 'To send a package to be plotted';
% Open figure window
fg=figure;
clf; axis; drawnow;
% Open udpsocket and bind udp port adress to it.
udp=pnet('udpsocket',lport);
% Use timeout to not block forever, makes it possible to update resized window.
try,
while 1,
% Wait/Read udp packet to reed buffer
len=pnet(udp,'readpacket');
if len>0,
% if packet larger then 1 byte then read maximum of 1000 doubles in network byte order
data=pnet(udp,'read',1000,'double');
figure(fg);
% .... and plot doubles in axis.
plot(data);
end
drawnow;
end
end
% On break or error close udpconnection and figure window.
pnet(udp,'close');
delete(fg);
return;