Changing lower bound of an array

6 views (last 30 days)
Huugin on 24 May 2013
Can I change the lower bound of an array. E.g can I have an array with starting index 0?
Will not work
Thanks for any suggestions!, and have a nice weekend :-)

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 24 May 2013
Example: y(n)=n^2+1 and you want to start from 0
for n=0:10
% y(1) correspond to index 0
  1 Comment
Azzi Abdelmalek
Azzi Abdelmalek on 24 May 2013
Edited: Azzi Abdelmalek on 24 May 2013
You can also use
y=@(n) n.^2+1

Sign in to comment.

Daniel Shub
Daniel Shub on 24 May 2013
I believe with a huge amount of work overloading some of the key functions (e.g., subsref and subsasgn) you can probably achieve a pretty seamless re-indexing interface. That said, even if it was easy, DO NOT DO IT. MATLAB uses 1-based indexing. Get used to it.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!