TomSym has the ability to analyze p-code for possible performance improvements and validation.
The following example illustrates how TomSym can be used:
1. Create a file called pcodetest.m with the following text:
function y = pcodetest(a,b)
y = sin(a)+b.^2-30;
2. Call "pcode pcodetest" to generate a pcoded file and delete the original m-file.
3. Execute the following in Matlab:
>> toms 3x1 a b
>> pcodetest(a,b)
ans = tomSym(3x1):
-30+(sin(a)+b.^2)
4. The function has now been analyzed and the constant separated.
5. Create a new m-file with the code from TomSym.