MATLAB: Accessing timer UserData fields

timer userdata

t=timer;
t.UserData = struct('field1', 'a', 'field2, 'b');
t.UserData.field1
% returns an error:
%inconsistently placed '.' in subscript expression
get(t.UserData, 'field1')
%returns an error:
%Conversion from double to struct not possible
get(get(t, 'UserData'), 'field1')
% returns same error
u = t.UserData;
u.field1 %works fine
Thus I have a workaround but it's kind of clunky: I set a variable to u=t.UserData at the beginning of my timer callback function and then set t.UserData=u at the end of my timercallback function
Why can't these fields be accessed directly?

Best Answer

Interesting, I had never seen that message before.
The work-around is
getfield(t.UserData, 'field1')