这是一个示例,说明如何通过网络发送数据(按照安迪的建议)并绘制当它生成时(即实时)。我也认为这种做法是最灵活/合适的。
To demonstrate, I will use a bash script that generates an
pair every 10th of a second, for the
function, in the range
:
#!/bin/bash
# script: sin.sh
for i in `seq 0 0.01 31.4`;
do
printf "$i, `echo "s($i)" | bc -l`\n"
sleep 0.1
done
(Don't forget to make this script executable!)
准备以下八度脚本(需要插座包!):
% in visualiseRobotData.m
pkg load sockets
s = socket();
bind(s, 9000);
listen(s, 1);
c = accept(s);
figure; hold on;
while ! isempty (a = str2num (char (recv (c, inf))))
plot (a(:,1), a(:,2), '*'); drawnow;
end
hold off;
现在按以下顺序执行:
- Run the
visualiseRobotData
script from the octave terminal.
(Note: this will block until a connection is established)
- 从 bash 终端运行:
./sin.sh | nc localhost 9000
并观察来自您的数据点的绘制情况sin.sh
script.