(translator=pacific, ChineseSource=pacific-20020609-7\end.html, EnglishSource=c:\matlabr12\help\techdoc\ref\end.html)
MATLAB Function Reference    
end

 for, while, switch, try, if 的結尾或表示最後一個索引。(indicate last index)

Syntax

    while expression            % (or if, for, or try)

    B = A(index:end,index)

Description

end 用來做 for, while, switch, try, if 的結束。若沒有 end 指令, for, while, switch, tryif 會等待更進一步的輸入(wait for further input)。每一個 end 和離本身最近且未被配成對的 for, while, switch, try, if 配在一起,以用來劃定其範圍。

 end 也可以用來表示最後一個索引。當使用到第k個索引時, end = (size(x,k))。這種用法的範例為 X(3:end)X(1,1:2:end-1)。若使用 end 增加陣列,例如 X(end+1)=5,可以先確保 X 索引的存在。

You can overload the end statement for a user object by defining an end method for the object. The end method should have the calling sequence end(obj,k,n), where obj is the user object, k is the index in the expression where the end syntax is used, and n is the total number of indices in the expression. For example, consider the expression

MATLAB will call the end method defined for A using the syntax

Examples

下列範例中 end 用來做 for, if的結尾。

下列範例中, end 用來做索引。

See Also

break, for, if, return, switch, try, while


 elseif eomday