www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/EvaluateMultipleConditionsInExpressionExample.m

    %% Evaluate Multiple Conditions in Expression
% Determine if a value falls within a specified range.

% Copyright 2015 The MathWorks, Inc.

x = 10;
minVal = 2;
maxVal = 6;

if (x >= minVal) && (x <= maxVal)
    disp('Value within specified range.')
elseif (x > maxVal)
    disp('Value exceeds maximum value.')
else
    disp('Value is below minimum value.')
end