简体   繁体   English

从命令行管道将数据馈入倍频程图

[英]Feeding data into octave plot from a command-line pipe

I have a question concerning real time plotting in octave. 我有一个关于八度实时绘图的问题。 The idea is very simple, but unfortunately I could not find a solution on the internet. 这个想法很简单,但是不幸的是我无法在互联网上找到解决方案。 In my project, I am using netcat to sample data and awk to filter it, for example: 在我的项目中,我正在使用netcat采样数据,并使用awk进行过滤,例如:

nc 172.16.254.1 23 | awk ' /point/ '

In this way, I get a new data point (approximately) every 4-10 ms, together with a timestamp. 这样,我每4-10毫秒(大约)获得一个新的数据点以及一个时间戳。 Now I would like to pipe this data to octave and plot it real time. 现在,我想将此数据通过管道传输到八度并实时绘制。 Does anyone have any ideas? 有人有什么想法吗?

Update 更新

It seems to me that 在我看来,这

nc 172.16.254.1 23 | awk ' /point/ ' | octave --silent --persist --eval "sample(stdin)"

pipes the data to my octave script sample , which does the plotting. 将数据通过管道传递到我的八度脚本sample ,该sample进行绘图。 But now there is still one problem: the replotting is far to slow, and slows down during sampling the data (I get thousands of data points). 但是现在仍然存在一个问题:重绘的速度远远不够,并且在数据采样期间速度变慢了(我得到了数千个数据点)。 I have 我有

function sample(stream)
t = NaN; r = NaN; k = 1;
figure(1)
plot(t,r,'o')
hold on
while(~feof(stream))
     s = fgets(stream);
     t(k) = str2double(s(1:6));
     r(k) = str2double(s(8:11));
     plot(t(k),r(k),'o')
     drawnow()
     k = k + 1;
end

What should I add/change? 我应该添加/更改什么?

After some research, feedgnuplot seems to satisfy my purpose of realtime plotting: 经过研究,feedgnuplot似乎满足了我实时绘图的目的:

nc 172.16.254.1 23 | 
awk ' /point/ ' | 
feedgnuplot --domain --points --stream 0.01

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM