3.0

3.0 | 1 rating Rate this file 1 Download (last 30 days) File Size: 509 Bytes File ID: #23868

Is this MATLAB or Octave?

by ioxv.4623

 

23 Apr 2009

Crude but effective tests of whether code is executed in matlab or octave.

| Watch this File

File Information
Description

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.
 
For example:

if uimatlab
   disp('This is MATLAB.')
elseif uioctave
   disp('This is Octave.')
else
   disp('I do not know what user environment this is.')
end

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
16 Jun 2009 Rody Oldenhuis

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
...
end

where type = 'matlab' if matlab, type = 'octave' if octave or something similar. That would be much more useful in most implementations...

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matlab ioxv.4623 23 Apr 2009 10:22:25
octave ioxv.4623 23 Apr 2009 10:22:25
modeling ioxv.4623 23 Apr 2009 10:22:25
gui ioxv.4623 23 Apr 2009 10:22:25

Contact us at files@mathworks.com