No, table variable names can't start with a number since they follow the same naming conventions as normal variables. The 'x'
is automatically added by readtable
to create a valid name. You should have noticed this warning when calling readtable
:
Warning: Variable names were modified to make them valid MATLAB identifiers.
The original names are saved in the VariableDescriptions property.
So, you can't get rid of the 'x'
within the table. But, if you need to do any comparisons, you can do them against the original values saved in the VariableDescriptions
property, which will have this format:
>> T.Properties.VariableDescriptions
ans =
1×2 cell array
'Original column heading: '99BM'' 'Original column heading: '105CL''
You can parse these with a regular expression, for example:
originalNames = regexp(T.Properties.VariableDescriptions, '''(.+)''', 'tokens', 'once');
originalNames = vertcat(originalNames{:});
originalNames =
2×1 cell array
'99BM'
'105CL'
And then use these in any string comparisons you need to do.