<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ブログ |</title><link>https://profile.tsaida.net/ja/blog/</link><atom:link href="https://profile.tsaida.net/ja/blog/index.xml" rel="self" type="application/rss+xml"/><description>ブログ</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>ja</language><lastBuildDate>Wed, 15 Feb 2023 17:10:22 +0900</lastBuildDate><image><url>https://profile.tsaida.net/media/icon_hu_ba54e489e247fac0.png</url><title>ブログ</title><link>https://profile.tsaida.net/ja/blog/</link></image><item><title>How to install matlab on wsl2</title><link>https://profile.tsaida.net/ja/blog/installing_matlab_to_wsl2/</link><pubDate>Wed, 15 Feb 2023 17:10:22 +0900</pubDate><guid>https://profile.tsaida.net/ja/blog/installing_matlab_to_wsl2/</guid><description>&lt;p&gt;How to install matlab on wsl2.&lt;/p&gt;
&lt;p&gt;I will show you the steps to install matlab on wsl2 and some tips to avoid common problems.&lt;/p&gt;
&lt;p&gt;Before we start, make sure you have wsl2 enabled on your Windows 10 system. You can check this by typing &lt;code&gt;wsl --list --verbose&lt;/code&gt; in the command prompt. You should see something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; NAME STATE VERSION
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;* Ubuntu-20.04 Running 2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don&amp;rsquo;t have wsl2 enabled, you can follow the instructions on
to install it.&lt;/p&gt;
&lt;p&gt;Also, make sure you have a graphical user interface (GUI) for wsl2. You can use any X server software for Windows. You can test if the GUI is working by typing &lt;code&gt;xeyes&lt;/code&gt; in wsl2. You should see a pair of eyes following your mouse cursor on the screen. If you have recently installed wsl2, you should be in this state from the beginning.
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="xeyes"
srcset="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/xeyes_hu_d822edae4f8b79a.webp 290w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/xeyes_hu_d822edae4f8b79a.webp"
width="290"
height="171"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s proceed to the matlab installation. First, download the matlab installer for Linux from the
. You will need to log in with your matlab account and select the version and platform you want. In this case, we will use matlab R2022b for Linux 64-bit. The file name should be something like matlab_R2022b_glnxa64.zip.&lt;/p&gt;
&lt;p&gt;You cannot use wget or curl to download the file, as you will need to accept the license agreement on the website. So, download the file directly from the website and save it to your Downloads folder in wsl2.
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="matlab download"
srcset="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_web_hu_5654875dc50663ae.webp 320w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_web_hu_af2456f012f326d4.webp 480w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_web_hu_b32576ca79bb91d8.webp 662w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_web_hu_5654875dc50663ae.webp"
width="662"
height="220"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;You may be tempted to start the installation right away, but there is one thing you need to do first. If you reboot wsl2, the mac address of the network interface will change, and this will cause problems with the matlab license activation. To avoid this, you need to fix the mac address of wsl2.&lt;/p&gt;
&lt;p&gt;To fix the mac address, add the following script to your ~/.bashrc file in wsl2. Replace (your mac address) with the mac address you want to use. You can find your current mac address by typing &lt;code&gt;ip link show&lt;/code&gt; in wsl2. The script is based on
on GitHub.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;mac&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;your mac address&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;gateway&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;ip route &lt;span class="p"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;&amp;#39;/default via /{print $3; exit}&amp;#39;&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; ! ip link show &lt;span class="p"&gt;|&lt;/span&gt; grep -q &lt;span class="nv"&gt;$mac&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip link &lt;span class="nb"&gt;set&lt;/span&gt; dev eth0 down
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip link &lt;span class="nb"&gt;set&lt;/span&gt; dev eth0 up
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip route add default via &lt;span class="nv"&gt;$gateway&lt;/span&gt; dev eth0
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip link &lt;span class="nb"&gt;set&lt;/span&gt; dev bond0 down
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip link &lt;span class="nb"&gt;set&lt;/span&gt; dev bond0 address &lt;span class="nv"&gt;$mac&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sudo ip link &lt;span class="nb"&gt;set&lt;/span&gt; dev bond0 up
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;/br&gt;&lt;/br&gt;
After adding the script, restart wsl2 by typing &lt;code&gt;wsl --shutdown&lt;/code&gt; in the command prompt and then launching it again.&lt;/p&gt;
&lt;p&gt;Now, you are ready to install matlab. Go to the Downloads folder in wsl2 and unzip the matlab installer file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Downloads
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;unzip matlab_R2022b_glnxa64.zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;/br&gt;&lt;/br&gt;
Then you will find the installer, run it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo &lt;span class="s2"&gt;&amp;#34;. /install&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;/br&gt;&lt;/br&gt;
The installer will launch and show you a graphical interface. Follow the instructions on the screen to complete the installation. You will need to log in with your matlab account, accept the license agreement, choose the installation folder and the products you want to install, and activate the license.
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="matlab install on wsl2"
srcset="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_install_hu_65c1afa45bcc5df2.webp 320w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_install_hu_fc300ee1b662886e.webp 480w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_install_hu_5fe138c8917ad349.webp 760w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_install_hu_65c1afa45bcc5df2.webp"
width="760"
height="498"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Finally, set the path so that you can start matlab with the &lt;code&gt;matlab&lt;/code&gt; command. Add the following line to the end of ~/.bashrc.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:/usr/local/MATLAB/R2022b/bin&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you type &lt;code&gt;matlab&lt;/code&gt; as a test, you will see the screen below and verify that it can be launched.
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="matlab start"
srcset="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_start_hu_c69aa8ef67cdc373.webp 320w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_start_hu_5b590006fabd204f.webp 480w, https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_start_hu_2970b00037b22120.webp 760w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://profile.tsaida.net/blog/installing_matlab_to_wsl2/matlab_start_hu_c69aa8ef67cdc373.webp"
width="760"
height="410"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Congratulations, you have successfully installed matlab on wsl2. You can now use matlab as you would on a Linux system.&lt;/p&gt;
&lt;p&gt;I hope this blog post was helpful for you to install matlab on wsl2. Thank you for reading.&lt;/p&gt;</description></item></channel></rss>