How to speed up UDP connections?
11 次查看(过去 30 天)
显示 更早的评论
I have to different versions of Matlab (6.5 and 7.11) communicating with each other. I use UDP as protocol. But it's very slow. Just to test the whole communication thing, I created to Simulations. Sim1 adds 5 to the incoming value, Sim2 subtracts 3. So Sim1 gets an initial value (in this case 1), calculates, gives the result to Sim2, where the same thing happens and so on. I want to calculate for 100 steps and it takes about 15s! Which is too long, cause in the real simulation I have ~400000 steps. How can I optimize the whole thing? Any ideas?
remotehost = '127.0.0.1';
remoteport = 10000;
u = udp(remotehost,remoteport,'LocalPort',10001);
fopen(u);
sample_time=0.1;
A=[1 1];
for sample=1:100
if isempty(A)
A=fread(u,2,'double');
end
num_ele=length(A);
for i=1:num_ele/2
udp_in(i,1)=A(2*i-1);
udp_in(i,2)=A(2*i);
end
sim('sim1',sample*sample_time)
A=[];
l2r=[sample*sample_time,udp_out(1)];
fwrite(u,l2r,'double')
end
fclose(u);
delete(u);
clear u;
5 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Beamforming and Direction of Arrival Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!