How to tell MATLAB from Freemat programmatically?
freemat, matlab, portability
Solution
Use `verstring` in the context of a `try` \ `catch`, the output in matlab will be an error while in Freemat it'll be something like "freemat 4.0", for example:
try
txt=verstring;
output='Freemat';
catch err
output='Matlab';
end
Problem
I have some code which I need to run both in MATLAB and in Freemat, using different service functions in each case. To make the whole thing portable I need to find a way to determine which functions to call at the start of my code, depending on which environment I am in. How does one do that? I was thinking of using the version command but no too sure if this is really robust.