You can do this already, as pointed out. HOWEVER, you should recognize that it will be less efficient
A = 3;
B.C.D.E = 3;
whos A B
Name Size Bytes Class Attributes
A 1x1 8 double
B 1x1 536 struct
See that B took up MUCH more storage than did A.
Also, you need to recognize that A.B and A.C are not different objects in MATLAB, but part of the same struct, A. In fact, if I try to create A.B now, it will get upset, because A already exists as a double.
A.B = 4
Warning: Struct field assignment overwrites a value with class "double". See MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures
Displays Warning, for details.
A =
B: 4
The original variable A no longer exists.
There are also time issues. The struct will be less efficient.
timeit(@() A+2)
Warning: The measured time for F may be inaccurate because it is close to the estimated time-measurement overhead (3.8e-07 seconds). Try measuring
something that takes longer.
> In timeit at 132
ans =
9.821e-07
timeit(@() B.C.D+2)
ans =
3.6342e-05
See that adding 2 to A is so fast that timeit has trouble measuring it. But adding 2 to B.C.D takes something on the order of 30 times as long.
So, in the end, you MAY be able to do what you want with a struct, but there are good reasons for not doing so, unless you have a very valid need for the dot. An alternate separator works better in the respects I've shown.
A = 3;
A_B_C_D = 3;
whos A*
Name Size Bytes Class Attributes
A 1x1 8 double
A_B_C_D 1x1 8 double
Computations will be equally fast with either of these variables.