Diff function: How to calculate the difference of two values

116 vues (au cours des 30 derniers jours)
Paul Hinze
Paul Hinze le 16 Jan 2021
Commenté : Paul Hinze le 16 Jan 2021
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

Réponses (1)

Cris LaPierre
Cris LaPierre le 16 Jan 2021
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 commentaires
Jan
Jan le 16 Jan 2021
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
Paul Hinze
Paul Hinze le 16 Jan 2021
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by