フィルターのクリア

Basic indexing question Find ismember

3 ビュー (過去 30 日間)
DIMITRY
DIMITRY 2016 年 3 月 8 日
コメント済み: DIMITRY 2016 年 3 月 8 日
Hi World,
I would like to create an index of a matrix based on a vector to resize this array by extracting the indexed rows:
X=(0.5:0.5:17)';
F=(1/52:1/52:30+1/52)';
Q=find(ismember(F,X));
But there are missing values from Q while I can see them in the workspace.
Can you help?

採用された回答

Stephen23
Stephen23 2016 年 3 月 8 日
編集済み: Stephen23 2016 年 3 月 8 日
You need to learn about the practical limits of floating point numbers.
Basically the numbers that you see are only decimal approximations of the real binary values stored in the computer's memory. With calculations involving decimal fractions these values can differ by a small amount even though they look they same when you look at them in the command window or variable viewer. However they will fail an equality test, and so are not considered to be equal, thus ismember does not match them.
You could use ismembertol instead.
Information on Floating Point Numbers
And some external links on this topic:
  2 件のコメント
DIMITRY
DIMITRY 2016 年 3 月 8 日
Hi Guys any idea?
DIMITRY
DIMITRY 2016 年 3 月 8 日
Thanks Steph!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by