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. For example, this allows 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 '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.
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 is compatible 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:
- Windows 10 (10.0.10586)
- Windows 8.1 Update 1 (6.3.9600)
- Windows 7 (6.1.7601)
- Windows 7 (6.1.7601), 32-bit
- Windows XP Pro SP3 (5.1.2600),32-bit
- macOS Sonoma (14.4.1)
- macOS Ventura (13.0.1)
- macOS Big Sur (11.2.3)
- macOS Catalina (10.15.7)
- macOS Sierra (10.12.1)
- OS X El Capitan (10.11.6)
- Ubuntu 16.04 LTS
- Ubuntu 15.10
- Ubuntu 14.04 LTS
- CentOS 7
- CentOS 6.8 (Final)
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. Thank you for any feedback or suggestions for improvement!
引用格式
Jorg Woehl (2024). detectOS (https://github.com/JorgWoehl/detectOS/releases/tag/v1.1.1), GitHub. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!无法下载基于 GitHub 默认分支的版本
版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.1.1 | See release notes for this release on GitHub: https://github.com/JorgWoehl/detectOS/releases/tag/v1.1.1 |
||
1.1.0.1 | See release notes for this release on GitHub: https://github.com/JorgWoehl/detectOS/releases/tag/v1.1.0.1 |
||
1.1 | See release notes for this release on GitHub: https://github.com/JorgWoehl/detectOS/releases/tag/v1.1 |
||
1.0.0.0 |
Small change in file description
|
|