Imagine the start and end values of a range being set from user input. They could be:
To extract this range from an array, I simply do:
But I'd like to save this range as one variable in itself, so that I can insert the range easily many places and only have to change it in one place such as:
This gives an error. MatLab will not store the a:b in this manner since : is a string and I thus am mixing strings with numbers. I could convert the a and b into a string with num2str, but then that range cannot be inserted into the x variable.
Is there a way to do this or do I have to manually put together the range with x(a:b) every time?