UIMATLAB returns true if the function is called from matlab, and false otherwise.
UIOCTAVE returns true if the function is called from octave, and false otherwise.
Using these functions, one is able to execute different parts of the code depending on what engine is performing the operations. Compatibility issues between MATLAB and Octave can thus be avoided.
disp('This is MATLAB.')
disp('This is Octave.')
disp('I do not know what user environment this is.')
ioxv.4623 (2020). Is this MATLAB or Octave? (https://www.mathworks.com/matlabcentral/fileexchange/23868-is-this-matlab-or-octave), MATLAB Central File Exchange. Retrieved .
hi there...basic question: I have lot of octave codes (my thesis). Can I efficiently turn it into matlab (at least at a main proportion, then I would refine manually).?????? Pls helps me!! best regards
You can also use switch with string cases.
I like this approach, because the alternative only checks if Octave is running the show, so if there is any Matlab alternative that runs the code, it will assume Matlab is running. Although I guess the chances of another mostly compatible alternative being developed are negligible for any foreseeable future.
apologies for the super late reply. Reason I didn't implement it like you suggested is that you then need a strcmp in your if ...elseif...else...end thing, whereas now each function returns true or false directly. Anyway, the difference is minor of course.
Have a good one,
Exactly what I was looking for, a nice trick indeed!
But I wondered...why didn't you put this in a single function? Like
function type = determineUI
where type = 'matlab' if matlab, type = 'octave' if octave or something similar. That would be much more useful in most implementations...