I am trying to call clear all from a simulink Level 1 S-function. I've take a look over doc mexCallMATLAB
but I do not know how to use it. I've wanted to clear the work space after my function is called.
Are you sure that you're writing a level-1 S-Function? If you are, then you shouldn't. These days both m-code and c-code S-Functions should all be written as level-2.
You haven't specifically indicated whether you are writing in m-code or c-code, but since you've mentioned mexCallMATLAB
it's assumed that you are using c-code, in which case you should use
mexEvalString("clear('all');");
If you're using m-code, then just use
evalin('base','clear all');