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

    %% Test Vector Elements  
% Find which vector elements are less than or equal to a given value.   

%% 
% Create a numeric vector. 
A = [1 12 18 7 9 11 2 15];  

%% 
% Test the vector for elements that are less than or equal to |12|. 
A <= 12 

%%
% The result is a vector with values of logical |1| (|true|) where the
% elements of |A| satisfy the expression.

%% 
% Use the vector of logical values as an index to view the values in |A|
% that are less than or equal to |12|.
A(A <= 12) 

%%
% The result is a subset of the elements in |A|.