working with a vector
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm dealing with a column vector with elements growing from top to bottom: I would like each element following the first to be subtracted from its previous one. Thanks for your suggestions
0 个评论
采纳的回答
Voss
2022-12-17
% a column vector:
x = [1;4;5;7;10]
% one way:
diff(x)
% another way:
x(2:end)-x(1:end-1)
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!