I am writing a simple MATLAB class that has a few properties and a method. The constructor of the class initializes the properties with the default values. The method of the cla
Your class needs to inherit from the handle superclass. Try:
classdef classTest < handle
properties
p1
p2
p3
p4
end
methods
function obj = classTest()
obj.p1 = 0;
obj.p2 = 0;
obj.p3 = [];
obj.p4 = '';
end
function obj = updateSomeProperties( obj, p1 )
obj.p1 = p1;
end
end
end
This will give,
>> b = classTest
b =
classTest with properties:
p1: 0
p2: 0
p3: []
p4: ''
>> b.updateSomeProperties(10)
ans =
classTest with properties:
p1: 10
p2: 0
p3: []
p4: ''
>> b
b =
classTest with properties:
p1: 10
p2: 0
p3: []
p4: ''