标题: MATLAB网口通信程序 [打印本页]

作者: sunyemei123    时间: 2017-12-16 10:11
标题: MATLAB网口通信程序
利用MATLAB可以实现在两台电脑之间快速传输图片。
  1. %网线直连,设置两台PC为同一局域网内(如192.168.1.101与192.168.1.102)
  2. %PC1:发端
  3. data=im2double(X);
  4. s = whos('data'); %提取数据参数
  5. s.size;
  6. s.bytes;
  7. tcpipServer = tcpip('192.168.1.1',55000,'NetworkRole','Server'); %设置对象属性
  8. set(tcpipServer,'OutputBufferSize',s.bytes); %设置缓存长度
  9. fopen(tcpipServer); %打开对象
  10. fprintf(t,'%s',['CLOCK 2.0000000000e+006' 13 10 10]);%设置频率
  11. fwrite(tcpipServer,zipped(:),'double'); %写入数据
  12. fclose(tcpipServer);
  13. %PC2:收端
  14. tcpipClient=tcpip('192.168.1.2',55000,'NetworkRole','Client');%设置对象属性
  15. set(tcpipClient,'InputBufferSize',4500000); %设置缓存长度
  16. set(tcpipClient,'Timeout',30); %设置连接时间
  17. fopen(tcpipClient); %打开连接对象
  18. rawData=fread(tcpipClient,562500,'double'); %接收数据,为行向量
  19. fclose(tcpipClient);
  20. reshapeData=reshape(rawData,375,500,3); %数据整理
  21. imshow(reshapeData) %绘图
复制代码

net.rar

653 Bytes, 下载次数: 9, 下载积分: 黑币 -5


作者: DuanYilin    时间: 2019-4-24 15:25
你好,有点问题请教下,方便留个联系方式吗




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1