OS = detectOS
returns the name of the operating system as a lowercase character vector, such as 'windows', 'macos' (which includes OS X), 'solaris', 'aix', 'ubuntu', 'centos', and many other Unix/Linux distributions. It is thus much more fine-grained than MATLAB's built-in ispc / ismac / isunix and 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.
detectOS was tested with various MATLAB releases on Windows 10, Windows 8.1 Update 1, Windows 7, Windows XP Pro SP3, macOS Big Sur, macOS Catalina, macOS Sierra, OS X El Capitan, Ubuntu 16.04 LTS, Ubuntu 15.10, Ubuntu 14.04 LTS, CentOS 7, and CentOS 6.8 (Final), and should run on a wide variety of other Unix/Linux distributions without modification.
See https://github.com/JorgWoehl/detectOS for more details.
Jorg Woehl (2021). detectOS (https://github.com/JorgWoehl/detectOS/releases/tag/1.1), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!