How can I find the second last value of a vector?
156 views (last 30 days)
Show older comments
Is there a command that returns the second last value in a value. For example, in vector W = [1 2 3 4...n], W(end) returns n, how would I return the n-1 value? Thanks
0 Comments
Accepted Answer
David Fletcher
on 3 Apr 2018
W(end-1)
2 Comments
Joseph Anchores
on 22 Aug 2021
I just tried this and matkab says "Array indices must be positive integers or logical values."
More Answers (0)
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!