Graphics Programs Reference
In-Depth Information
delete(h(1:2))
We can now issue the correct text command:
text(-.7,f(-.7),'f(x)')
Let us write an m-file to do this automatically. We'll call it oops . When
we call oops without any argument, it should delete the last object
drawn in the current axes. When called with an integer argument, n ,
oops should delete the last n objects drawn in the current axes. The
following m-file is a possible solution. (The function nargin returns the
number of arguments with which a function was called.)
function oops(N)
% OOPS Delete the last object plotted on the axes.
% Repeating "oops" erases farther back in time.
% OOPS does not work for title and labels; to
% erase these, use "title('')" or "xlabel('')"
if nargin = =0N=1;end
h = get(gca,'children');
delete(h(1:N));
Let us see if oops works:
clf
plt(x,f(x))
hold on
plt(x,f(x/2))
Nowwedoan oops to get rid of the shallow parabola,
oops
Now plot the shallow one again with a different line style:
Search WWH ::




Custom Search