In the past, I've been making extensive use of Matlab's table
class.
This very simple code, inside a script or at the prompt, works as expected:
varNames = {'Date_time', 'Concentration_1', 'Concentration_2'};
testTable = array2table(zeros(5,3), 'VariableNames', varNames)
Now, I have the same table
as the property
of a handle class
.
classdef TestClass < handle
properties
testTable (:,3) table
end
methods
function testMethod(obj)
varNames = {'Date_time', 'Concentration_1', 'Concentration_2'};
obj.testTable = array2table(zeros(5,3), 'VariableNames', varNames);
obj.testTable.Properties.VariableNames
end
end
end
If I execute the following at the command prompt, the zeros
are assigned to the table
, but the VariableNames
keep their default value, i.e., {'Var1', 'Var2'}
etc.
tc = TestClass; tc.testMethod
Even tc.testTable.Properties.VariableNames = varNames
does not change them.
Is this a bug, or am I missing something? (I am using Matlab R2017b)