I do not understand. Are you explicitly creating variables in the workspace
when running in the function context? If no, then why do you think if you
create a variable inside a function, then it will also be created in
When you exit a function, then all the variables it created inside the
function are gone.
To clear variables in the workspace, do help 'clear'