Question

I'm writing a function which ought to plot to an already created axes. The function provides the option to re-title the axes, and I'm trying to make that functionality work.

If the axes doesn't already have a title then just calling title() works, of course.

But: If the axes does already have a title, then calling title() overprints the original title, but leaves the original in place.

So: I've been experimenting with set():

T_old = get(gca, 'Title');
T_new = set(T_old, 'String', 'New Title');

Which leaves me the error message:

One or more output arguments not assigned during call to "set".

What am I doing wrong? Are there other arguments which must be set for the Title handle? And if so what?

Was it helpful?

Solution

Set does not have any output arguments, thus call set(T_old, 'String', 'New Title'); without any return variables.

OTHER TIPS

From the help for set:

A = set(H, 'PropertyName')
set(H,'PropertyName')
returns or displays the possible values for the specified property of the object with handle H. The returned array is a cell array of possible value strings or an empty cell array if the property does not have a finite set of possible string values.

However, you're calling set and and actually setting a property value. This is not a valid input pattern. Just call this instead:

set(T_old, 'String', 'New Title');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top