{"id":8935,"date":"2017-11-10T09:00:21","date_gmt":"2017-11-10T14:00:21","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8935"},"modified":"2017-11-07T14:41:35","modified_gmt":"2017-11-07T19:41:35","slug":"mac-address","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/11\/10\/mac-address\/","title":{"rendered":"Get Computer MAC Address"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63737-get-computer-mac-address\">Get Computer MAC Address<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2685526\">Xiangrui Li<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>What is a MAC Address and what is it used for?  I like the description in <a href=\"https:\/\/www.howtogeek.com\/169540\/what-exactly-is-a-mac-address-used-for\/\">the answer to this howtogeek question<\/a>.\n   <\/p>\n<p>The reason I need to know my MAC Address and Wireless MAC Address is for a written property pass to bring my laptop onto<br \/>\n      restricted customer sites or to have my laptop authorized for internet access at customer sites.\n   <\/p>\n<p>There are commands you can run that vary by operating system which I&#8217;ve always had to search for, so Xiangrui&#8217;s file makes<br \/>\n      this easy.  His function is platform agnostic, and has a set of fallback algorithms sorted based on speed.\n   <\/p>\n<p>It&#8217;s pretty simple, you can ask for one or all MAC Addresses.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">m = MACAddress<\/pre>\n<pre style=\"font-style:oblique\">m =\r\n    '54-E1-AD-55-55-55'\r\n<\/pre>\n<p>Or if you want all of them:<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">m = MACAddress(1)'<\/pre>\n<pre style=\"font-style:oblique\">m =\r\n  4&times;1 cell array\r\n    {'54-E1-AD-55-55-55'}\r\n    {'AC-ED-5C-55-55-55'}\r\n    {'AC-ED-5C-55-55-55'}\r\n    {'AC-ED-5C-55-55-55'}\r\n<\/pre>\n<p>My only feedback would be to have another option which returns a <tt>table<\/tt> with the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/table.html#mw_cb8d6608-0cf9-4164-b1f8-7bce6caa23ce\"><i>RowNames<\/i><\/a> indicating which MAC Address each represents.\n   <\/p>\n<h3>Comments<a name=\"4\"><\/a><\/h3>\n<p>Do you have a use for getting the MAC address within MATLAB?<\/p>\n<p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8935#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63737-get-computer-mac-address#comments\">comment<\/a> for Xiangrui.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_54b7183315394233841258e05214d880() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='54b7183315394233841258e05214d880 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 54b7183315394233841258e05214d880';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_54b7183315394233841258e05214d880()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017b<\/p>\n<\/div>\n<p><!--\n54b7183315394233841258e05214d880 ##### SOURCE BEGIN #####\n%% MAC Address\n%\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63737-get-computer-mac-address MAC Address> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2685526 Xiangrui Li>.\n% \n\n%% \n% What is a MAC Address and what is it used for?  I like the description in\n% <https:\/\/www.howtogeek.com\/169540\/what-exactly-is-a-mac-address-used-for\/\n% the answer this howtogeek question>.\n%\n% The reason I need to know my MAC Address, and Wireless MAC Address is for\n% a written property pass to bring my laptop onto restricted customer sites\n% or to have my laptop authorized for internet access at customer sites.\n% \n% There are commands you can run that vary by operating system which\n% I've always had to search for, so Xiangrui's file makes this easy.  His\n% function is platform agnostic, and has a set of fallback algorithms\n% sorted based on speed.\n%\n% It's pretty simple, you can ask for one or all MAC Addresses.\n\nm = MACAddress\n\n%%\n% Or if you want all of them:\n\nm = MACAddress(1)'\n\n%%\n% My only feedback would be to have another option which returns a |table|\n% with the <https:\/\/www.mathworks.com\/help\/matlab\/ref\/table.html#mw_cb8d6608-0cf9-4164-b1f8-7bce6caa23ce _RowNames_> indicating which MAC Address each represents.\n\n%% Comments\n% \n% Do you have a use for getting the MAC address within MATLAB?\n%\n% Give it a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8935#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63737-get-computer-mac-address#comments\n% comment> for Xiangrui.\n%\n##### SOURCE END ##### 54b7183315394233841258e05214d880\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/pick\/files\/2017-11-07_11-25-18.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>Sean&#8216;s pick this week is Get Computer MAC Address by Xiangrui Li.<\/p>\n<p>What is a MAC Address and what is it used for?  I like the description in the answer to this howtogeek&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/11\/10\/mac-address\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":8938,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8935"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8935"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8935\/revisions"}],"predecessor-version":[{"id":8940,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8935\/revisions\/8940"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media\/8938"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}