MATLAB R2018a and later
Starting in MATLAB R2018a, you can use the "WindowState" property to maximize, minimize, or display a figure in full-screen mode.
This is the recommended approach for versions of MATLAB R2018a onward.
To maximize a window and retrieve its full position in the monitor:
>> f = figure('WindowState','maximized');
Unfortunately if the "pause" command is not present inside the script, it returns the original position faster than the figure maximizes, so in your function, I recommend including this "pause" to ensure the full screen position is calculated. The length of the "pause" may need to be increased for older systems.
MATLAB R2017b and earlier
As a workaround for MATLAB 7.4 (R2007a) through MATLAB R2017b, the attached files maxfig.p, minfig.p and figstate.p (with help files maxfig.m, minfig.m and figstate.m) allow you to perform these actions as follows:
s = figstate(F)
Please note that querying the figure position immediately after using these functions may not work reliably unless the figure resize is complete.
There are no workarounds for versions prior to MATLAB 7.4 (R2007a).