MATLAB: Overwrite data in figure but keep axis labels, title, and legend

axisfigurelegendMATLABoverwritetitle

Hi,
I would like to overwrite only the data presented in a figure while keeping the labels and legends the same. I do not want to waste space and time on re-labeling the figures. 'hold on' holds the plot but does not overwrite the existing data and only adds to it.
Thank you for your help.

Best Answer

h=plot(rand(1,100));
title('random signal');
legend('blue signal');
set(h,'XData',1:10,'YData',1:10);
Related Question