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