Documentation for overloading builtin end() class method..?

조회 수: 3(최근 30일)
Bradley Stiritz
Bradley Stiritz 2013년 6월 18일
Hi everyone,
I need to find official documentation / examples for overloading the builtin classdef 'end' method. I have an example in my code base which I got from somewhere a couple of years ago, but unfortunately I didn't document where I got the code from! Here's a correctly-working method from one of my classdefs:
function outIndex = end(obj,~,~)
outIndex = obj.Nvalues;
assert(outIndex>0,'Invalid use of method end() for empty vector');
I'm looking for a URL or two please that documents what those two trailing arguments refer to..? I can't seem to locate anything via Google or the R2013a Help Window.
Thanks, Brad

채택된 답변

Matt J
Matt J 2013년 6월 18일
The information you're requesting is in "doc end", available from the command line. To quote,
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
The MATLAB software calls the end method defined for A using the syntax
  댓글 수: 1
Bradley Stiritz
Bradley Stiritz 2013년 6월 18일
Thanks Matt, I appreciate your help.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by