How can I realize such a function (plot realtime data and respond to key press event at the same time)
1 view (last 30 days)
Show older comments
Say a vector called S_vector, each second it gets updated by adding a new S, initially, S =1, then whenever a keyboard is pressed, S = S+1. I have realized the realtime plot of S_vector as follows, but not the keyboard part.
S_vector = 0; %initialize S_vector
t= timer('period', 1); %a timer to make sure the interval is 1s
set (t, 'executionmode', 'fixedrate');
set (t, 'timerfcn', ['S_vector = [S_vector;s];',...
'plot(0:1:(length(s_vector)-1), s_vector);']);
start(t);
Can anyone suggest how can I capture the keyboard event as the timer going on?
I tried set(gcf, 'buttondownfcn', 'S=S+1;'), it doesn't work.
Help me please.
Thank you
0 Comments
Answers (0)
See Also
Categories
Find more on Programming Utilities in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!