In Matlab, extra variables can be stored at each time step in MBS_user and then logged in userfctR/user_DirDyn_io.m file.
A more elegant and more robust solution is to use the user_model structure (see “How can I define user variables or parameters?”).