MATLAB: How to call the variables of MATLAB workspace from a function

functionsmdfsaveworkspace

I am trying to make a .mat file from withing a functioin that contains all the variables in the MALTAB workspace but when I attempt to do that from inside a function using save('NAMEWORKSPACE'); it saves all the variables from the workspace of the function in the .mat file and I dont want that.
How can create a .mat file with the variables from my MATLAB workspace from inside a function?
Please advice,

Best Answer

Do you have a good reason for doing this?
Hint:
function save_base_workspace()
evalin( 'base', 'save( ''save_base_workspace.mat'' );' )
end