min function why do results change for numbers with decimal values?

ex1:
X=[1:11];
Y=double( 1.0*X);
diffY = diff(Y);
[diffY_min,diffY_index] = min (diffY);
ans diffY_min = 1 diffY_index=1
ex2:
X=[1:1.4:15];
Y=double( 1.0*X);
diffY = diff(Y);
[diffY_min,diffY_index] = min (diffY);
ans diffY_min = 1.4 diffY_index=8
all numbers are double prec. Why does min treat numbers N.xxx different than N? Get similar results if I change slope fm 1 to 2.1 or sqrt(2) or any value that results in diffY .NE. 1,2,3....

1 件のコメント

SteveH
SteveH 2015 年 12 月 9 日
thanks. That explains why the diff values aren't exactly equal.

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

回答 (2 件)

Stephen23
Stephen23 2015 年 12 月 9 日

0 投票

カテゴリ

ヘルプ センター および File ExchangeHelp and Support についてさらに検索

タグ

質問済み:

2015 年 12 月 9 日

コメント済み:

2015 年 12 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by