"Hold on" function doesn't work when use set function to dynamically plot data
Ältere Kommentare anzeigen
Hello, I am currently trying to plot 3 axis-acceleration data dynamically in Matlab in 3 subplot figures. The code is
subplot(3,2,2)
hp1 = plot(1, c1(1, 1),'--rs','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','r',...
'MarkerSize',3);
axis([ 0,ceil(nFrames*1.03),-6,6]);
title('Acceleration Data in X Axis')
hold on
subplot(3,2,4)
hp2 = plot(1, c2(1, 1),'--rs','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',3);
axis([ 0,ceil(nFrames*1.03),-6,6])
title('Acceleration Data in Y Axis')
hold on
subplot(3,2,6)
hp3 = plot(1, c3(1, 1),'--rs','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
axis([ 0,ceil(nFrames*1.03),-6,6])
title('Acceleration Data in Z Axis')
hold on
for k = 2 : nFrames
set(hp1, 'XData', k, 'YData', c1(k,1));
set(hp2, 'XData', k, 'YData', c2(k,1));
set(hp3, 'XData', k, 'YData', c3(k,1));
pause(0.03)
end
I found hold on function doesn't work based on this case since I want to retain each point on the figure rather than only plotting the current one.
Does any one know how to solve that problem?
Thanks,
Joe
Antworten (2)
John Petersen
am 1 Dez. 2014
Try
set(hp1, 'XData', [get(hp1, 'Xdata'); k], 'YData', [get(hp1,'Ydata'); c1(k,1)]);
Yasmeen
am 14 Jan. 2014
0 Stimmen
Have you tried "hold all"?
1 Kommentar
Jihang Wang
am 14 Jan. 2014
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!