update instance property data without creating a new object?
Mostra commenti meno recenti
How can I update a property without creating a new instance, using an instance method? For example:
classdef TestClass
properties
A = [];
end
methods
function obj=updateA(obj, val)
obj.A = val;
end
end
end
This will update A:
x = TestClass
x.A = 5;
However,
x.updateA(10)
will not update the instance x, but will create a new instance with the modified A. How can I update the property A of x using a class method without creating a new instance?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Construct and Work with Object Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!