Can you use animatedline with subplot, using addpoints (MATLAB2016a)
Show older comments
I am trying to use addpoints (with animatedline) in order to create an animated figure in a subplot. The code works on its own, but as soon as it's added to a subplot, it only plots the axes.
% Create random signals
time = 1:100;
signal_1 = rand(100,1);
signal_2 = rand(100,1);
% For plotting correlation line..need all values first
corr_line = animatedline;
for start_point = 0:80
sig1_cut = signal_1(start_point+1:start_point+1+19);
sig2_cut = signal_2(start_point+1:start_point+1+19);
corr_pre = corrcoef(sig1_cut,sig2_cut);
corr_fin(start_point+1) = corr_pre(2,1);
end
x_plot = 0:80;
n = 1;
subplot(3,1,1)
axis([-0.1 80 -1 1])
for start_point = 0:80
addpoints(corr_line,x_plot(n),corr_fin(n))
drawnow
n = n+1;
pause(0.01)
end
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Animation 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!