Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the documentation for the "end" keyword in Octave? (for indexing)

Tags:

octave

I was trying to figure out what the following Octave code does:

degree = 6;
out = ones(size(X1(:,1)));
   for i = 1:degree
    for j = 0:i
        out(:, end+1) = (X1.^(i-j)).*(X2.^j);
    end
end

I wasn't sure what the end+1 meant in Octave until I found the answer for Matlab here: What is the `end+1` line doing here? The accepted answer links to the Matlab official documentation which is very clear: https://www.mathworks.com/help/matlab/ref/end.html

I'm trying to find the documentation for this same keyword in the Octave documentation but I can't seem to find it. I've searched in the Documentation tab (Octave 5.1.0), using the function index and the search tab to no avail although I see it used in several documentation pages.

like image 732
Diego F. Rodríguez V. Avatar asked Nov 20 '25 11:11

Diego F. Rodríguez V.


1 Answers

The Octave documentation, which seems to be categorized more by usage than keyword, on Index Expressions is also as explicit:

In index expressions the keyword end automatically refers to the last entry for a particular dimension. This magic index can also be used in ranges and typically eliminates the needs to call size or length to gather array bounds before indexing.

like image 113
TroyHaskin Avatar answered Nov 23 '25 09:11

TroyHaskin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!