computer

Identifies the computer platform that is running the program.

Category: Environment and Settings > Platform and License

Syntax

c = computer

Returns the platform code as a character vector.

Description

computer is used by scripts that must choose a file path, a compiled library or a command depending on the operating system. For a simple test of the family of systems, ispc, ismac and isunix are shorter and read better.

The code is determined by the machine that runs the program, so the printed value differs between computers.

Output arguments

c
Platform code such as 'PCWIN64' (Windows), 'GLNXA64' (Linux), 'MACI64' (Intel Mac) or 'MACA64' (Apple silicon).

Example

Check the platform code

c = computer;
class(c)
ismember(c, {'PCWIN64','GLNXA64','MACI64','MACA64'})
Output
ans = 'char'
ans = logical
   1

See also

ispc ismac isunix version ver