標(biāo)題: MATLAB網(wǎng)口通信程序 [打印本頁]

作者: sunyemei123    時(shí)間: 2017-12-16 10:11
標(biāo)題: MATLAB網(wǎng)口通信程序
利用MATLAB可以實(shí)現(xiàn)在兩臺(tái)電腦之間快速傳輸圖片。
  1. %網(wǎng)線直連,設(shè)置兩臺(tái)PC為同一局域網(wǎng)內(nèi)(如192.168.1.101與192.168.1.102)
  2. %PC1:發(fā)端
  3. data=im2double(X);
  4. s = whos('data'); %提取數(shù)據(jù)參數(shù)
  5. s.size;
  6. s.bytes;
  7. tcpipServer = tcpip('192.168.1.1',55000,'NetworkRole','Server'); %設(shè)置對(duì)象屬性
  8. set(tcpipServer,'OutputBufferSize',s.bytes); %設(shè)置緩存長度
  9. fopen(tcpipServer); %打開對(duì)象
  10. fprintf(t,'%s',['CLOCK 2.0000000000e+006' 13 10 10]);%設(shè)置頻率
  11. fwrite(tcpipServer,zipped(:),'double'); %寫入數(shù)據(jù)
  12. fclose(tcpipServer);
  13. %PC2:收端
  14. tcpipClient=tcpip('192.168.1.2',55000,'NetworkRole','Client');%設(shè)置對(duì)象屬性
  15. set(tcpipClient,'InputBufferSize',4500000); %設(shè)置緩存長度
  16. set(tcpipClient,'Timeout',30); %設(shè)置連接時(shí)間
  17. fopen(tcpipClient); %打開連接對(duì)象
  18. rawData=fread(tcpipClient,562500,'double'); %接收數(shù)據(jù),為行向量
  19. fclose(tcpipClient);
  20. reshapeData=reshape(rawData,375,500,3); %數(shù)據(jù)整理
  21. imshow(reshapeData) %繪圖
復(fù)制代碼

net.rar

653 Bytes, 下載次數(shù): 9, 下載積分: 黑幣 -5


作者: DuanYilin    時(shí)間: 2019-4-24 15:25
你好,有點(diǎn)問題請(qǐng)教下,方便留個(gè)聯(lián)系方式嗎




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1