You can change the figure size and keep the position centered using the following code:
main.m481 chars19 lines
This code creates a plot and then gets the current figure position and size using gcf
(get current figure), which returns a handle to the current figure. It then calculates the new figure width and height (here, 50% larger) and the new figure position based on the current position, and sets these using the Position
property of the figure handle.
Note that this code assumes that the current figure is in the center of the screen. If the figure is not centered, you may need to adjust the calculation of the new position accordingly.
gistlibby LogSnag