12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

text(-.7,f(-.7),’f(X)’)But we have made a mistake: the “x” should be lower case. We try tocorrect it by issuing another text comm<strong>and</strong> with a lower case “x”:text(-.7,f(-.7),’f(x)’)But this has printed over the top <strong>of</strong> the previous label, making a mess.Without starting again, we can use the delete function to delete thetext objects, once we know their h<strong>and</strong>les. We can get a list <strong>of</strong> the h<strong>and</strong>les<strong>of</strong> the line <strong>and</strong> the text objects by getting all the children <strong>of</strong> the currentaxes:>> h = get(gca,’children’)h =19.000118.000111.0005The variable h is a three-element column vector (the actual values arenot important). These are the h<strong>and</strong>les corresponding to the Line object(parabola) <strong>and</strong> the two Text objects. But which <strong>of</strong> them is the Lineobject <strong>and</strong> which are the Text objects? We can get the object typescorresponding to these h<strong>and</strong>les by typing:>> types = get(h,’type’)types =’text’’text’’line’(The variable types is returned as a cell array.) A parent’s childrenare always listed in reverse age order: the most recently drawn objectappears first—youngest first, oldest last. This tells us that the first twoelements <strong>of</strong> the vector h correspond to the text objects ‘f(X)’ <strong>and</strong> ‘f(x)’,in that order, <strong>and</strong> the third element corresponds to the parabolic line.We can delete the two text objects by typing:c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!