Strange behavior of diff()

조회 수: 3 (최근 30일)
Paul
Paul 2016년 2월 25일
답변: Paul 2018년 3월 14일
Hi all,
I'm using 2012b and I'm trying to find the difference between successive elements of a vector of uint64 numbers. Here's some of them, but I get very puzzling results form diff(). For instance:
a = [4648759972
4648759972
4651621722
4652352784
4652733003
4653926753]
Then diff(a) gives the wrong result:
[5166781
5166781
2305031
1573969
1193750]
However diff(a(1:2)) gives the correct result: 0. Also diff(a(2:3)) gives the correct result: 2861750
I've been searching for an explanation but I did not find a similar problem ever reported, and I don't understand what is happening. Can anybody explain to me what is going on here?
Thanks a lot!
Paul
  댓글 수: 8
Walter Roberson
Walter Roberson 2016년 2월 27일
And to ask more directly,
which diff(uint64(0))
that will ensure you get the correct function shown for whatever uint64 is resolving to for you.
Paul
Paul 2018년 3월 14일
Thanks Walter; an external toolbox rerouted the call to an external diff function with bad behavior. Deleting that function solved all problems. Sorry for the late reply.

댓글을 달려면 로그인하십시오.

채택된 답변

Paul
Paul 2018년 3월 14일
Problem solved; external diff function caused bad behavior; deleting this external function solved the problem.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by