What does determine the time to update plot?
3 views (last 30 days)
Show older comments
Hello everyone and thanks advance to read my questions.
I have make real time recording program. It has 32ch (it means 32 ea subplots) and each channel updated. I used bellow code to update my plot and check the time to update.
tic
set(DataLine, {'Ydata'}, num2cell(signal, 2)
% DataLine is 32 x 1 cell and signal 32 x 4000 matrix
toc
the code update same size matrix every time, but elapsed time is variable from about 2 to 7 ms Because I have make very strict recording program, I want the elapsed time will not variable. How can I update plot in very strict time?
And I have one more question! Different with above, I draw 20 number of plot which have 40 samples at each subplot (32 figure * 20 plot * 40 samples = 25,600) I think it will have short updating time than above (32 figure * 4000 samples = 128,000) because, It has less number of data, but when I update that by bellow, it need longer time!
set(DataLine(:,:), {'Ydata'}, num2cell(cell2mat(spike),2));
% spike 32 x 1 cell that each cell has 20 x 40 matrix
Is any body can help me? thanks!
0 Comments
Accepted Answer
Jan
on 26 Jul 2017
Edited: Jan
on 27 Jul 2017
Part 1: The update of the figures is triggered by drawnow or pause. As you have obeserved correctly, the times are varying and this is expected in Matlab. It depends on many different factors, e.g. other programs, the graphics board, network traffic, hard disk fragmentation, amount of free RAM, etc. Neither Matlab nor your operating system is designed for a fixed rate of processing.
Part 2: As you see the number of data is less important than the number of drawn objects. It is much more expensive to draw 2 lines with 1000 points, than 1 line with 2000 points.
The num2cell(cell2mat()) construct might waste time. See FEX: Cell2Vec - cell2mat seems to have problems with the pre-allocation.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!