What exponentia means is he can ' t run this code . You can do it bc you have a and b in your workspace . If you use clear all , and then try to run the code you shared you ' ll see the same error . Secondly he ' s making a good point about using set . set is a function to change properties of object . In this case the object should be the plot , which you can access by using the first return value of the plot function , which is called a function handle . With seth , ' XData ', a 1 n , ' YData ', b 1 n you can update the data that underlies the plot you ' r seeing , and with a subsequent drawnow you can update the view to represent the current data underlying the plot . Works perfectly , and is more efficient than plot , but imho a bit to complicated and unnecessary for this specific application .