Borrar filtros
Borrar filtros

Unable to Overload Subsasgn

4 visualizaciones (últimos 30 días)
Andrew Barton
Andrew Barton el 20 de Sept. de 2012
Comentada: sst el 22 de Feb. de 2019
I'm trying to write a class that overloads the subsasgn function, but I am running into this rather cryptic error:
Class 'MyClass' is not allowed to define a 'subsasgn' method.
Since most of the documentation and discussion about subsasgn comes from the perspective of overloading it, I'm somewhat at a loss to determine why I cannot do this, so basically any suggestion of what might be happening is appreciated.
I'm subclassing dynamicprops, matlab.mixin.Heterogeneous, and matlab.mixin.Copyable. I was worried that it wasn't allowed to overload subsasgn with a class that subclasses dynamicprops, but I've tested that and it works fine in other cases.
I'm on R2012a.
This question follows up on the one I asked here, but since it's since it's separate I thought making a fresh one would be ok: http://www.mathworks.com/matlabcentral/answers/48406-setter-methods-for-dynamic-properties
  2 comentarios
Daniel Shub
Daniel Shub el 21 de Sept. de 2012
Please post the example code that does not work.
sst
sst el 22 de Feb. de 2019
I was wondering, are there any other base classes that introduce a restriction on overloading subsasgn? I am inheriting from the Simulink.Parameter class and trying to overload the subsasgn function.

Iniciar sesión para comentar.

Respuesta aceptada

Daniel Shub
Daniel Shub el 21 de Sept. de 2012
The documentation is pretty clear on this:
"Cannot Redefine Indexing or Concatenation
The use of heterogeneous arrays requires consistent indexing and concatenation behaviors. Therefore, subclasses of matlab.mixin.Heterogeneous cannot change their default indexed reference, indexed assignment, or concatenation behavior.
You cannot override the following methods in your subclasses:
cat
horzcat
vertcat
subref
subsasign
In cases involving multiple inheritance in which your subclass inherits from superclasses in addition to matlab.mixin.Heterogeneous, the superclasses cannot define any of these methods."
  2 comentarios
Andrew Barton
Andrew Barton el 21 de Sept. de 2012
Ah, well, that's a bummer. Given that your answer to this question makes your fix to my previous problem not work in my case, is there any way for me to reopen that question, or can I repost it? I'm new to Matlab answers and don't have a great grasp of the etiquette here yet.
Also thank you for being so helpful.
Daniel Shub
Daniel Shub el 21 de Sept. de 2012
I think posting it as a new question with the new requirement would be fine. Please post some example code (full class file) along with the expected output and any edge cases.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by