1 |
function screensizecheck(SZ) |
---|
2 |
%SCREENSIZECHECK Check the current screen resolution. |
---|
3 |
% SCREENSIZECHECK([width height]) compares the current screen |
---|
4 |
% resolution to the width and height given (in pixels). If the |
---|
5 |
% current screen size is smaller than either width or height, an |
---|
6 |
% appropriate error message is generated. |
---|
7 |
% |
---|
8 |
% Example: |
---|
9 |
% ------- |
---|
10 |
% Generate an error if the screen resolution is smaller than |
---|
11 |
% 800x600. |
---|
12 |
% |
---|
13 |
% screensizecheck([800 600]); |
---|
14 |
% |
---|
15 |
% See also VERSIONCHECK |
---|
16 |
|
---|
17 |
% Jordan Rosenthal, 11-Sep-1999 |
---|
18 |
|
---|
19 |
oldUnits = get(0,'units'); |
---|
20 |
set(0,'units','pixels'); |
---|
21 |
ScreenSize = get(0,'ScreenSize'); |
---|
22 |
set(0,'units',oldUnits); |
---|
23 |
if any( ScreenSize(1:2) ~= [1 1] ) |
---|
24 |
msg = ['The screen resolution was changed while Matlab was ', ... |
---|
25 |
'running. An accurate measurement of the screen size ', ... |
---|
26 |
'is only taken when Matlab starts. Therefore, please ', ... |
---|
27 |
'restart Matlab and run this program again.']; |
---|
28 |
error(msg); |
---|
29 |
end |
---|
30 |
if ScreenSize(3)<SZ(1) | ScreenSize(4)<SZ(2) |
---|
31 |
strSize = [num2str(SZ(1)) 'x' num2str(SZ(2))]; |
---|
32 |
msg = ['Screen resolution should be ' strSize ' or higher. '... |
---|
33 |
'To use this program you must increase your screen ', ... |
---|
34 |
'resoluion, RESTART Matlab, and run the program again.']; |
---|
35 |
error(msg); |
---|
36 |
end |
---|
37 |
|
---|
38 |
|
---|