Pregunta

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:

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. 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. 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?

¿Fue útil?

Solución

After some research, feedgnuplot seems to satisfy my purpose of realtime plotting:

nc 172.16.254.1 23 | 
awk ' /point/ ' | 
feedgnuplot --domain --points --stream 0.01
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top