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

    %% Elements Equal to Specific Values
% To find a specific integer value, use the |==| operator. For instance,
% find the element equal to |13| in a 1-by-10 vector of odd integers.

% Copyright 2015 The MathWorks, Inc.

x = 1:2:20

%%
%
k = find(x==13)

%%
% To find a noninteger value, use a tolerance value based on your data.
% Otherwise, the result is sometimes an empty matrix due to floating-point
% roundoff error.
y = 0:0.1:1

%%
%
k = find(y==0.3)

%%
%
k = find(abs(y-0.3) < 0.001)