How do I detect a M1 mac processor in MATLAB?

Viewed 438

Is there a way of detecting a M1 mac in MATLAB? MATLAB has ismac but that presumably won't differentiate between processor types.

1 Answers

To detect the processor one can call to the system command line: Detect Apple Silicon from command line

Note, this has not been tested on a m1 mac ...

if ismac()
    [~,result] = system('uname -m');
    is_m1_mac = strcmp(strtrim(result),'arm64');
else
    is_m1_mac = false;
end

Note, this would help if you are running an older version of MATLAB, as MATLAB doesn't officially support M1 macs until 2020b update 3 ... https://www.mathworks.com/matlabcentral/answers/641925-is-matlab-supported-on-apple-silicon-macs

However, it is not clear to me that this would eventually detect execution of MATLAB natively vs via ROSETTA (when a native option actually exists).

Related