标题:
MATLAB网口通信程序
[打印本页]
作者:
sunyemei123
时间:
2017-12-16 10:11
标题:
MATLAB网口通信程序
利用MATLAB可以实现在两台电脑之间快速传输图片。
%网线直连,设置两台PC为同一局域网内(如192.168.1.101与192.168.1.102)
%PC1:发端
data=im2double(X);
s = whos('data'); %提取数据参数
s.size;
s.bytes;
tcpipServer = tcpip('192.168.1.1',55000,'NetworkRole','Server'); %设置对象属性
set(tcpipServer,'OutputBufferSize',s.bytes); %设置缓存长度
fopen(tcpipServer); %打开对象
fprintf(t,'%s',['CLOCK 2.0000000000e+006' 13 10 10]);%设置频率
fwrite(tcpipServer,zipped(:),'double'); %写入数据
fclose(tcpipServer);
%PC2:收端
tcpipClient=tcpip('192.168.1.2',55000,'NetworkRole','Client');%设置对象属性
set(tcpipClient,'InputBufferSize',4500000); %设置缓存长度
set(tcpipClient,'Timeout',30); %设置连接时间
fopen(tcpipClient); %打开连接对象
rawData=fread(tcpipClient,562500,'double'); %接收数据,为行向量
fclose(tcpipClient);
reshapeData=reshape(rawData,375,500,3); %数据整理
imshow(reshapeData) %绘图
复制代码
net.rar
2017-12-16 10:10 上传
点击文件名下载附件
下载积分: 黑币 -5
653 Bytes, 下载次数: 9, 下载积分: 黑币 -5
作者:
DuanYilin
时间:
2019-4-24 15:25
你好,有点问题请教下,方便留个联系方式吗
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1