@goc3 that broke my test! Seems there is some implicit scoping rule, by adding the %% it means that T is not available in subsequent %% cells. Fixed it by calling the user function multiple times. This stuff is not well documented: the scoping rules, the need for a leading %% etc.