Support Articles
Graphics
Maximizing a Figure Using M-Code
A couple of users have asked how they can maximize their figures automatically from m-code. The solution is extremely simple, requiring only the figure's position property to be setup.
The code below simply generates a figure in it's default size.
peaks;
shading interp;
lighting phong;
z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ...
- 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ...
- 1/3*exp(-(x+1).^2 - y.^2)

The figure can be maximized by setting up the figure's 'position' property correctly. The 'position' property is set to a vector value of the form: [Left Bottom Width Height]. So this property also sets the size the figure, by specifying the Width and Height values. In order to maximize the figure size we need to find the size of the computer screen. The code below sets the figure's size to that of the computer screen.
set(gcf,'position',get(0,'screensize'))
