How to determine if my matlab code is running in Matlab instead of Octave?

10 views (last 30 days)
We know that Octave can also run some matlab code, but if I want to make sure my code is running in true matlab instead of Octave, what code can I use to detrmine it? Thank you.

Answers (2)

Image Analyst
Image Analyst on 5 Feb 2014
Look at the title bar I'd guess. Or check the "About" box. What did you click to even run either one? Don't you know what icon you clicked on? Or did you click a .m file instead of an executable?
  5 Comments
Christopher Crawford
Christopher Crawford on 17 Nov 2021
Edited: Christopher Crawford on 17 Nov 2021
MatlabR2019b says
'ctfroot' requires one of the following:
MATLAB Compiler
MATLAB Compiler SDK
It may be dangerous, but I used something similar:
if strfind(path,'MATLAB') 1, else 0, end
Image Analyst
Image Analyst on 17 Nov 2021
Edited: Image Analyst on 17 Nov 2021
@Christopher Crawford Did you try this on the command line?
>> ctfroot
ans =
'C:\Program Files\MATLAB\R2021b'
I do have the compiler toolbox though.
Alternatively you can inspect prefdir
if strfind(prefdir, 'MATLAB')
% MATLAB is running.
end

Sign in to comment.


Ahmed Salah
Ahmed Salah on 10 Nov 2023
Edited: Ahmed Salah on 10 Nov 2023
Look at this answer on StackOverflow

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!