Rev | Line | |
---|
[37] | 1 | function index = end(X,position,numindices) |
---|
| 2 | %END (overloaded) |
---|
| 3 | |
---|
| 4 | % Author Johan Löfberg |
---|
| 5 | % $Id: end.m,v 1.1 2005/10/12 16:05:54 joloef Exp $ |
---|
| 6 | |
---|
| 7 | switch numindices |
---|
| 8 | case 1 |
---|
| 9 | % User has written someting like X(end) |
---|
| 10 | sizes = size(double(X)); |
---|
| 11 | if min(sizes)>1 |
---|
| 12 | index = prod(sizes); |
---|
| 13 | else |
---|
| 14 | index = max(sizes); |
---|
| 15 | end |
---|
| 16 | case 2 |
---|
| 17 | sizes = size(double(X)); |
---|
| 18 | index = sizes(position); |
---|
| 19 | otherwise |
---|
| 20 | error('Indexation dimension cannot exceed 2'); |
---|
| 21 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.