Understanding Figure Windows & Changing Their Apperances

1 次查看(过去 30 天)
Hello all
I was wondering if anyone could shed any light on creating figure windows.
Currently I am creating a figure window with the following command:-
Stress = figure(34);
set(Stress,'Name','Stress Experiment');
This command works and gives me the following result:-
But rather then use 2 x seperate lines of code I wanted to create the same result with a single line of code, so I used the following command:-
Stress = figure('Name','Stress Experiment','Number',34)
But this command keeps giving me an error which states:-
I dont understand why i am getting this error?
Why cannot i amend the Number property?
Can anyone help?
Thank you.

采纳的回答

Stephen23
Stephen23 2019-11-17
"Why cannot i amend the Number property?"
Because the 'Number' property is read only:
The primary reason for this is to prevent conflicts: every figure has a number, which is defined as soon as the object is created. Note also that figure numbers are unique: there are absolutely no duplicate figure numbers. If the user could define the figure number, how should MATLAB deal with the conflicts?
I guess what you expect is that those properties should be applied to an existing figure with that number, much like this syntax:
fhg = figure(n);
set(fgh,...)
but consider what happens with your syntax when the arguments are parsed (from left to right): at first a new object is created, then some of its properties are set, then later you define the number (read only!) of an already existing figure: what should happen to the new figure object that was just created? Should it be deleted, or the existing figure deleted, or the two objects somehow merged?
That is why there is one specific syntax for obtaining/creating a figure with a specific figure number:
fgh = figure(n);
which does not lead to any conflicts about which figure object has what properties.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by