detectOS returns the name and version number of the operating system.
For the development of cross-platform apps in MATLAB, it is useful to know the operating system (OS) on which MATLAB is running, e.g. to select native fonts and font sizes (see getOSfont) or to fine-tune the layout and design of graphical user interface elements. detectOS returns the name and version number of the underlying OS for a wide range of platforms and OS versions.
OS = detectOS returns the name of the operating system as a lowercase character vector, such as
'macos' (which includes OS X),
'centos', and many other Unix/Linux distributions. It is thus much more fine-grained than MATLAB's built-in
computer functions. If the OS cannot be determined, an error is thrown.
[OS, OSVersion] = detectOS also returns the OS version number as a numeric row vector. For example, Windows 7 SP1 (version 6.1.7601) is reported as
OS = 'windows' and
OSVersion = [6, 1, 7601]. If the OS version cannot be determined, a warning is issued and the empty numeric array is returned.
For a list of Windows releases, see https://en.wikipedia.org/wiki/Ver_(command).
For a list of macOS releases, see https://support.apple.com/en-us/HT201260.
detectOS is compatible with MATLAB R2016b and later releases (version 1.0 iscompatible with R2013a and later releases). It was tested on the following operating systems (64-bit, unless otherwise stated) and should run on a wide variety of other Unix/Linux distributions without any modification:
Another great tool returning information about the CPU and operating system is CPU Info. Unfortunately, CPU Info does not differentiate between Unix/Linux distributions, and does not return sensible information about the OS version in these cases. Adding this capability was the main motivation for developing detectOS.
Please let me know if you have tested detectOS on other operating systems. Any feedback or suggestions for improvement are welcome!
Jorg Woehl (2021). detectOS (https://github.com/JorgWoehl/detectOS/releases/tag/v220.127.116.11), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!