Getting error "Output argument "varargout{2}" (and maybe others) not assigned during call to "MyClass/subsref"."

2 ビュー (過去 30 日間)
I am getting this error "Output argument "varargout{2}" (and maybe others) not assigned during call to "MyClass/subsref"."
A couple of things: subsref is overloaded for MyClass. varargout should return a 1x1 cell. varargout{1} is assigned appropriately just before the function return. The function call works when called from the Command Window but not when called from another higher level class. This code works on another computer with the Matlab 2015a but not on my computer with Matlab 2016a.
I have no idea what else to do. I really need this code to work on this computer. Could it be a compiler error or am I missing something? Thank you!
  5 件のコメント
Kristofer Womack
Kristofer Womack 2016 年 9 月 14 日
The function call is:
result(:,i) = transpose(staggered17D.LDV(n,m,:).z);
It is called within a function of class LDVexperiment. staggered17D is a class called LDVexperiment which contains a 3-dimensional matrix called LDV. LDV is a subclass called LDVpoint under staggered17D. z is a 'double' property of LDV. subsref had to be overloaded in order to handle the ':' operator in the subclass LDVpoint. This should return a 'double' vector of property z. i, n, and m are all integer indexes. result is initially undefined. This function call gives the following error.
Output argument "varargout{2}" (and maybe others) not assigned during call to "LDVpoint/subsref".
If this same line is executed from the MATLAB Command Window with all the required variables in the workspace, it does not give the error. The error only comes when this line is called from a function in the class LDVexperiment. Again, the error does not occur in MATLAB 2015a but does occur in MATLAB 2016a.
I hope this helps. I am grateful for any help you can provide.
Kristofer Womack
Kristofer Womack 2016 年 9 月 15 日
I upgraded to MATLAB 2016b and the problem still exists.
I installed MATLAB 2015a on the same machine and the code works without error.

サインインしてコメントする。

採用された回答

Kristofer Womack
Kristofer Womack 2018 年 6 月 6 日
You have to add the following code to the class in order to overload the Matlab default for numArgumentsFromSubscript(obj,s,indexingContext):
function n = numArgumentsFromSubscript(obj,s,indexingContext)
n = 1;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by