Error using diff(X) command

조회 수: 3 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by