Adding dynamic property to existing class definition

5 visualizaciones (últimos 30 días)
Ennis
Ennis el 9 de Feb. de 2024
Respondida: Vidip el 20 de Mzo. de 2024
I have a classdef (I am not allowed to share it) to which I want to add a property that can be accessed only when explicitly called. It also needs to be dynamic. How do I go about doing it? The addprop function is not working and error says that property is not defined in the classdef
  2 comentarios
Matt J
Matt J el 9 de Feb. de 2024
Editada: Matt J el 9 de Feb. de 2024
to add a property that can be accessed only when explicitly called
Could you elaborate on what this means? What would it mean by contrast to implicitly call a property?
The addprop function is not working and error says that property is not defined in the classdef
It would help to see copy/pastes error message.

Iniciar sesión para comentar.

Respuestas (1)

Vidip
Vidip el 20 de Mzo. de 2024
I understand that you want to add a property that can be accessed when called and needs to be dynamic. To add a dynamic property to a class instance, the class must be a subclass of the ‘dynamicprops’ class. The properties of the ‘meta.DynamicProperty’ class correspond to property attributes. Dynamic properties are not defined in classdef blocks, but you can set their attributes by setting the ‘meta.DynamicProperty’ object properties.
Add a dynamic property to an object using the ‘addprop’ method of the dynamicprops class. The addprop method returns a ‘meta.DynamicProperty’ instance representing the new dynamic property.
For further information, refer to the documentation links below:

Categorías

Más información sobre Properties 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