Diff function: How to calculate the difference of two values
67 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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])
2 个评论
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 Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!