Error using diff(X) command

8 ビュー (過去 30 日間)
Abdullah Abdullah
Abdullah Abdullah 2014 年 7 月 11 日
コメント済み: kurt sundell 2017 年 3 月 9 日
Hello all,
I am trying to store the difference of vector elements into an other vector. I have also seen the syntax using help command but still it persists.
Here is what I do
X = [1 1 2 3 5 8 13 21];
Y = diff(X)
the erorr is : Index exceeds matrix dimensions.
when I do difference of decimal numbers like
X = [0.001 0.001 0.002 0.003 0.005 0.008 0.0013 0.0021];
Y = diff(X)
Error says : "Subscript indices must either be real positive integers or logicals."
If diff(X) is only valid for integers, can some one suggest which alternative to use getting difference of adjacent decimal(floating point) elements of vector.
Regards Abdullah

採用された回答

Honglei Chen
Honglei Chen 2014 年 7 月 11 日
編集済み: Honglei Chen 2014 年 7 月 11 日
You probably have a workspace variable named diff
  2 件のコメント
Abdullah Abdullah
Abdullah Abdullah 2014 年 7 月 11 日
Yes the problem solved after clear.
Thanks
kurt sundell
kurt sundell 2017 年 3 月 9 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by