function mac = macaddress()
%MACADDRESS   Return mac address
%  MAC = MACADDRESS returns the MAC addresses of the computer

if isunix()
    macexpr = '[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}';
    [~,b]=system('ifconfig');
    mac = regexp(b, sprintf('HWaddr (?<mac>(%s)', macexpr), 'names');
    mac = lower(mac.mac);
elseif ispc()
    macexpr = '[0-9a-fA-F]{2}-){5}[0-9a-fA-F]{2}';
    [~,b]=system('ipconfig -all');
    mac = regexp(b, sprintf('(?<mac>(%s)', macexpr), 'names');
    mac = {mac(:).mac}';
    mac = lower(strrep(mac, '-', ':'));
    mac = mac(~strcmp(mac, '00:00:00:00:00:00'));
else
    error 'unknown computer type';
end

end
