Overloaded subsref function with varargout, nargout is incorrect

조회 수: 14 (최근 30일)
LukeAC
LukeAC 2016년 6월 7일
댓글: LukeAC 2016년 6월 7일
I have created an overloaded subsref function for a class definition I've created to emulate the table datatype in R2011b. The function works robustly in R2015b, but when I use it in R2011b the value returned for nargout is wrong.
For example, with 0-1 output arguments, nargout returns numel(obj). With >=2 output arguments, the value returned for nargout is correct.
I created a simple function in R2011b which uses varargout to test, but it showed no such problem.
I have also created an overloaded numel function within the same class definition file. All of the methods are defined within the same script. Would this cause a conflict in R2011b to call the wrong numel function when calling nargout?
Thanks for any tips, -Luke

채택된 답변

LukeAC
LukeAC 2016년 6월 7일
I've checked and confirmed the interference of the overloaded numel function. Commenting it out of the class definition eliminates the error. I opened the numel documentation and found the warnings with regard to creating an overloaded numel function and the subsequent effect on the subsref and subsasgn functions. I will continue investigating, as I need the overloaded numel function. -Luke
  댓글 수: 1
LukeAC
LukeAC 2016년 6월 7일
Attempted using dbstack to identify caller function to create an exception for numel call from the class definition file, but with no success. I'm going to remove the overloaded numel function and replace anywhere it is called in other scripts with prod(size(obj))

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Special Characters에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by