You can use end to indicate the last element. data(2:end) returns a vector containing the elements in the data vector from element 2 to the last element. Or, if data is an array of characters, it returns the second character to the last character. And data(end) returns the last element.
This can also be done using matrices, i.e. data(2:end,5:end) . In addition, you can use it as an operand, i.e. data(2:end-1) , data(2:end/2) .
In this context, end serves a different purpose from using functions / loops / switches at the end.
Js ng source share