How can I code vector index plus
2 次查看(过去 30 天)
显示 更早的评论
n is an index of vector. C is a vector. How can I code that? Cn + C(n+1) C(n+1) is next(+1) index of n.
0 个评论
采纳的回答
John D'Errico
2016-3-5
Code what? If n is an integer, then
C(n) + C(n+1)
does exactly that.
Are you asking to form the sum of all consecutive pairs of elements? Be explicit about your question. Once you are able to ask a clear question, the answer is often trivial.
n = numel( C );
C(2:n) - C(1:(n-1))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!