Terminate block of code, or indicate last array index
parfor statements. Without an
parfor wait for further input. Each
paired with the closest previous unpaired
parfor and serves to delimit its scope.
end also marks the termination of a function.
Although it is sometimes optional, use
better code readability. If your function contains one or more nested
functions, then you must terminate every function in the file, whether
nested or not, with
end. This includes primary,
nested, private, and local functions.
If your script contains local functions, then you must terminate
every local function in the file with
end function also serves as the last
index in an indexing expression. In that context,
the same as
size(X,k) when used as part of the
index into array
X. Examples of this use are
select the third through final elements of the array, and
select all even elements of the first row, excluding the last element.
end to grow an array, as in
X exists first.
end to close a
for loop and an
a = [0 0 1 1 0 0 0 1 0]; for k = 1:length(a) if a(k) == 0 a(k) = 2; end end
Access the last row of a matrix
A = magic(3)
A = 3×3 8 1 6 3 5 7 4 9 2
B = A(end,1:end)
B = 1×3 4 9 2
Classes can overload the
to implement specialized behavior. For more information, see end as Object Index.
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).