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

    %% Test Vector Elements  
% Determine if vector elements are greater than a given value.   

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

%% 
% Test the vector for elements that are greater than |10|. 
A > 10 

%%
% 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 greater than |10|. 
A(A > 10) 

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