Diff function: How to calculate the difference of two values

조회 수: 60 (최근 30일)
Paul Hinze
Paul Hinze 2021년 1월 16일
댓글: Paul Hinze 2021년 1월 16일
Hey,
for a bigger task i need to use the diff function.
When I type in:
diff(12.22, 13.22) it should me give a 1 back, instead i get an error. Why?
thanks for comments

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 1월 16일
Syntax error. See the doc page. You are asking it to take the diff of 12.22 13.22 times. All the values you want to take the difference of need to be in the first input. Try this.
diff([12.22,13.22])
ans = 1
  댓글 수: 2
Jan
Jan 2021년 1월 16일
Exact.
The first step in case of an error is do ask help or doc to explain the syntax of the command:
help diff
% If this is not exhaustive enough:
doc diff

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by