linux 使用 matlab
linux
本文字数:3.3k 字 | 阅读时长 ≈ 19 min

linux 使用 matlab

linux
本文字数:3.3k 字 | 阅读时长 ≈ 19 min

1. matlab 安装

这个没有 root 权限的话应该是很难安装的,我没有 root 权限捣鼓了一天没安装成功。主要是没有办法 mount 镜像(mount 是需要 root 权限的),开了 docker 也没用,而且我在本地解压镜像传输到服务器上也没用(win 和 linux 解压出来的文件有差异,不知道在本地 linux 上解压会怎么样),就没再折腾了。

在容器中安装 matlab,必须加 privileged,不然容器中无法挂载 matlab 镜像 docker run -it --privileged --name matlab docker.kt.io/mmitgroup/wangyh/pure:cuda118_ubuntu20_py310_zsh_v1 /bin/zsh,然后下载一个 matlab 安装包,这里以 ·R2021a_Linux.iso· 为例子,下载完之后,安装相关依赖

sudo apt update
sudo apt install -y mount
# 支持 matlab 中依赖包,不然安装了无法打开 matlab
sudo apt install -y libxt6 libxmu6 libxpm4 libxft2 libxext6 libxrender1 libxi6 libxinerama1 libxrandr2 libfreetype6 fontconfig

然后挂载即可

➜ matlab sudo mount -o loop R2021a_Linux.iso /mnt/matlab_iso
mount: /mnt/matlab_iso: WARNING: device write-protected, mounted read-only.
cd ~
mkdir ~/Matlab_R2021a
touch ~/installer_input.txt
vim ~/installer_input.txt

把下面内容加入进去

##################################################################
##
## Use this file to specify parameters required by the installer at runtime.
##
## Instructions for using this file.
##
## 1. Create a copy of this template file and fill in the required
##    information.
##
## 2. Uncomment only those lines that start with a single '#'
##    and set the desired values. All allowed values for the
##    parameters are defined in the comments section for each
##    parameter.
##
## 3. Launch the installer from the command line, using the -inputFile option
##    to specify the name of your installer initialization file.
##
##    (Windows) setup.exe -inputFile <file_name>
##    (Linux/macOS) install -inputFile <file_name>
##
##################################################################
##
##
## SPECIFY INSTALLATION FOLDER
## 
## Example:
##        (Windows) destinationFolder=C:\Program Files\MATLAB\RXXXX
##        (Linux) destinationFolder=/usr/local/RXXXX
##        (macOS) destinationFolder=/Applications
##
## Set the desired value for destinationFolder and
## uncomment the line.
 
destinationFolder=/root/Matlab_R2021a  
 
##
## SPECIFY FILE INSTALLATION KEY
##
## Example: fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx.....
##
## Set the desired value for fileInstallationKey and
## uncomment the line.
##
 
fileInstallationKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
 
##
## ACCEPT LICENSE AGREEMENT
##
## You must agree to the license agreement to install MathWorks products.
## The license agreement can be found in the license_agreement.txt file at the
## root level of the installation DVD.
##
## Example: agreeToLicense=yes
##
## Set agreeToLicense value to yes or no and
## uncomment the line.
 
agreeToLicense=yes
 
##
## SPECIFY OUTPUT LOG
##
## Specify full path of file into which you want the results of the
## installation to be recorded.
##
## Example:
##            (Windows) outputFile=C:\TEMP\mathworks_<user_name>.log
##            (Linux/macOS) outputFile=/tmp/mathworks_<user_name>.log
##
## Set the desired value for outputFile and
## uncomment the line.
 
outputFile=/root/matlab_install.log 
 
##
## Enable Login Named User licensing
##
## Set to Yes to enable use of a Login Named User license for all users of this MATLAB installation
## Users must log in to their MathWorks Account when MATLAB starts.
##
## Example: enableLNU=yes
##
## NOTE: This flag is valid in silent installations only.
 
# enableLNU=yes
 
##
## IMPROVE MATLAB
##
## Improve MATLAB by sending user experience information to MathWorks.
## Your participation ensures that you are represented and helps us design
## better products. You can opt in or out of this service either during
## installation or by going to MATLAB preferences.
## https://www.mathworks.com/support/faq/user_experience_information_faq.html
 
improveMATLAB=yes
 
########## Begin: Options for Network License Types #########
##
## SPECIFY PATH TO LICENSE FILE (Required for network license types only)
##
## This value is required when installing as a Network End-User
## Example:
##            (Windows) licensePath=C:\TEMP\license.dat
##            (Linux) licensePath=/tmp/license.dat
## Set the desired value for licensePath and
## uncomment the line.
 
licensePath=/root/network.lic 
 
########## End: Options for Network License Types #########
 
 
################# Begin - Windows Only Options ################
## 
## CHOOSE TO SET FILE ASSOCIATIONS
## 
## Set to true if you want the installer to associate file types used by MathWorks
## products to this version of MATLAB, or false if you do not want the installer to
## associate MathWorks file types with this version of MATLAB.
##
## Default value is true.
##
## Set setFileAssoc value to true or false and
## uncomment the line.
 
# setFileAssoc=true
 
##
## CHOOSE TO CREATE WINDOWS DESKTOP SHORTCUT
##
## Set to true if you would like the installer to create a desktop shortcut icon
## when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is false.
##
## Set desktopShortcut value to true or false and
## uncomment the line.
 
# desktopShortcut=false
 
## CHOOSE TO ADD SHORTCUT TO WINDOWS START MENU
##
## Set to true if you would like the installer to create a Start Menu shortcut
## icon when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is true.
##
## Set startMenuShortcut value to true or false and
## uncomment the line.
 
# startMenuShortcut=true
 
## CREATE a MATLAB Startup Accelerator task
##
## The MATLAB Startup Accelerator installer creates a
## system task to preload MATLAB into the system's cache
## for faster startup.
##
## NOTE: By default, a MATLAB Startup Accelerator task will
## automatically be created.
##
## If you want a MATLAB Startup Accelerator task to be created,
## do not edit this section.
##
## Set createAccelTask value to false if you do not want to
## create an Accelerator task and uncomment the line.
 
# createAccelTask=true
 
################ End - Windows Only Options ################
 
## SPECIFY PRODUCTS YOU WANT TO INSTALL
##
## By default, the installer installs all the products and
## documentation for which you are licensed. Products you are not licensed for
## are not installed, even if they are listed here.
##
## Note:
## 1. To automatically install all your licensed products, do not edit
##    any lines in this section.
## 
## 2. To install a specific product or a subset of products for
##    which you are licensed, uncomment the line for the product(s) you want
##    to install.
 
#product.5G_Toolbox
#product.AUTOSAR_Blockset
#product.Aerospace_Blockset
#product.Aerospace_Toolbox
#product.Antenna_Toolbox
#product.Audio_Toolbox
#product.Automated_Driving_Toolbox
#product.Bioinformatics_Toolbox
#product.Communications_Toolbox
#product.Computer_Vision_Toolbox
#product.Control_System_Toolbox
#product.Curve_Fitting_Toolbox
#product.DDS_Blockset
#product.DO_Qualification_Kit
#product.DSP_System_Toolbox
#product.Data_Acquisition_Toolbox
#product.Database_Toolbox
#product.Datafeed_Toolbox
#product.Deep_Learning_HDL_Toolbox
#product.Deep_Learning_Toolbox
#product.Econometrics_Toolbox
#product.Embedded_Coder
#product.Filter_Design_HDL_Coder
#product.Financial_Instruments_Toolbox
#product.Financial_Toolbox
#product.Fixed-Point_Designer
#product.Fuzzy_Logic_Toolbox
#product.GPU_Coder
#product.Global_Optimization_Toolbox
#product.HDL_Coder
#product.HDL_Verifier
#product.IEC_Certification_Kit
#product.Image_Acquisition_Toolbox
#product.Image_Processing_Toolbox
#product.Instrument_Control_Toolbox
#product.LTE_Toolbox
#product.Lidar_Toolbox
#product.MATLAB
#product.MATLAB_Coder
#product.MATLAB_Compiler
#product.MATLAB_Compiler_SDK
#product.MATLAB_Parallel_Server
#product.MATLAB_Production_Server
#product.MATLAB_Report_Generator
#product.MATLAB_Web_App_Server
#product.Mapping_Toolbox
#product.Mixed-Signal_Blockset
#product.Model_Predictive_Control_Toolbox
#product.Model-Based_Calibration_Toolbox
#product.Motor_Control_Blockset
#product.Navigation_Toolbox
#product.OPC_Toolbox
#product.Optimization_Toolbox
#product.Parallel_Computing_Toolbox
#product.Partial_Differential_Equation_Toolbox
#product.Phased_Array_System_Toolbox
#product.Polyspace_Bug_Finder
#product.Polyspace_Bug_Finder_Server
#product.Polyspace_Code_Prover
#product.Polyspace_Code_Prover_Server
#product.Powertrain_Blockset
#product.Predictive_Maintenance_Toolbox
#product.RF_Blockset
#product.RF_Toolbox
#product.ROS_Toolbox
#product.Radar_Toolbox
#product.Reinforcement_Learning_Toolbox
#product.Risk_Management_Toolbox
#product.Robotics_System_Toolbox
#product.Robust_Control_Toolbox
#product.Satellite_Communications_Toolbox
#product.Sensor_Fusion_and_Tracking_Toolbox
#product.SerDes_Toolbox
#product.Signal_Processing_Toolbox
#product.SimBiology
#product.SimEvents
#product.Simscape
#product.Simscape_Driveline
#product.Simscape_Electrical
#product.Simscape_Fluids
#product.Simscape_Multibody
#product.Simulink
#product.Simulink_3D_Animation
#product.Simulink_Check
#product.Simulink_Code_Inspector
#product.Simulink_Coder
#product.Simulink_Compiler
#product.Simulink_Control_Design
#product.Simulink_Coverage
#product.Simulink_Design_Optimization
#product.Simulink_Design_Verifier
#product.Simulink_Desktop_Real-Time
#product.Simulink_PLC_Coder
#product.Simulink_Real-Time
#product.Simulink_Report_Generator
#product.Simulink_Requirements
#product.Simulink_Test
#product.SoC_Blockset
#product.Spreadsheet_Link
#product.Stateflow
#product.Statistics_and_Machine_Learning_Toolbox
#product.Symbolic_Math_Toolbox
#product.System_Composer
#product.System_Identification_Toolbox
#product.Text_Analytics_Toolbox
#product.UAV_Toolbox
#product.Vehicle_Dynamics_Blockset
#product.Vehicle_Network_Toolbox
#product.Vision_HDL_Toolbox
#product.WLAN_Toolbox
#product.Wavelet_Toolbox
#product.Wireless_HDL_Toolbox

注意这里面的内容,要改为你自己的

destinationFolder=/root/Matlab_R2021a,
outputFile=/root/matlab_install.log 
licensePath=/root/network.lic
fileInstallationKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

然后依次执行以下命令然后等待安装即可,大概要半小时到一小时不等

sudo chmod 444 ~/installer_input.txt
cd /mnt/matlab_iso
chmod a+x -R ./*
cd ~
cd Matlab_R2021a
chmod a+x -R ./
cd ~
sudo /mnt/matlab_iso/install -inputFile ./installer_input.txt    

如果要看安装进度,可以先进入一个容器 docker exec -it matlab /bin/zsh,然后看相应的 log 文件日志

Matlab_R2021a  installer_input.txt  matlab  matlab_install.log  matlab_install.log.lck  network.lic
➜ ~ cat matlab_install.log
(Dec 13, 2025 07:27:55) ##################################################################
(Dec 13, 2025 07:27:55) #
(Dec 13, 2025 07:27:55) # Today's Date: 
(Dec 13, 2025 07:27:55) Sat Dec 13 07:27:54 UTC 2025
(Dec 13, 2025 07:27:55) 
(Dec 13, 2025 07:27:55) System Info
(Dec 13, 2025 07:27:55) OS: Linux 5.4.0-169-generic
(Dec 13, 2025 07:27:55) Arch: amd64
(Dec 13, 2025 07:27:55) Data Model: 64
(Dec 13, 2025 07:27:55) Language: en
(Dec 13, 2025 07:27:55) Java Vendor: Oracle Corporation
(Dec 13, 2025 07:27:55) Java Home: /mnt/matlab_iso/sys/java/jre/glnxa64/jre
(Dec 13, 2025 07:27:55) Java Version: 1.8.0_202
(Dec 13, 2025 07:27:55) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Dec 13, 2025 07:27:55) Release Description: R2021a
(Dec 13, 2025 07:27:55) Java Class Path: /mnt/matlab_iso/java/jarext/connector_impl/cosg_impl_java/cosg_impl.jar:/mnt/matlab_iso/java/config/matlab_installer/pathlist.jar
(Dec 13, 2025 07:27:55) User Name: root
(Dec 13, 2025 07:27:55) Current Directory: /root
(Dec 13, 2025 07:27:55) Installer build number: 9.10.0.1602886
(Dec 13, 2025 07:27:55) Input arguments: 
(Dec 13, 2025 07:27:55) inputfile: ./installer_input.txt
(Dec 13, 2025 07:27:55) mode: silent
(Dec 13, 2025 07:27:55) licensepath: /root/network.lic
(Dec 13, 2025 07:27:55) fileinstallationkey: 16657-12924-57317-61852-64286-55909-29981-03510-24434-28468-38451-45120-49755-02098-16579-18499-47846-29482-07890-49002-49502-17398-33753-40310
(Dec 13, 2025 07:27:55) root: /mnt/matlab_iso
(Dec 13, 2025 07:27:55) outputfile: /root/matlab_install.log
(Dec 13, 2025 07:27:55) improvematlab: yes
(Dec 13, 2025 07:27:55) destinationfolder: /root/Matlab_R2021a
(Dec 13, 2025 07:27:55) agreetolicense: yes
(Dec 13, 2025 07:27:55) flow: fikworkflow
(Dec 13, 2025 07:27:55) Input file:
##################################################################
##
## Use this file to specify parameters required by the installer at runtime.
##
## Instructions for using this file.
##
## 1. Create a copy of this template file and fill in the required
##    information.
##
## 2. Uncomment only those lines that start with a single '#'
##    and set the desired values. All allowed values for the
##    parameters are defined in the comments section for each
##    parameter.
##
## 3. Launch the installer from the command line, using the -inputFile option
##    to specify the name of your installer initialization file.
##
##    (Windows) setup.exe -inputFile 
##    (Linux/macOS) install -inputFile 
##
##################################################################
##
##
## SPECIFY INSTALLATION FOLDER
## 
## Example:
##        (Windows) destinationFolder=C:\Program Files\MATLAB\RXXXX
##        (Linux) destinationFolder=/usr/local/RXXXX
##        (macOS) destinationFolder=/Applications
##
## Set the desired value for destinationFolder and
## uncomment the line.
 
destinationFolder=/root/Matlab_R2021a  
 
##
## SPECIFY FILE INSTALLATION KEY
##
## Example: fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx.....
##
## Set the desired value for fileInstallationKey and
## uncomment the line.
##
 
fileInstallationKey=16657-12924-57317-61852-64286-55909-29981-03510-24434-28468-38451-45120-49755-02098-16579-18499-47846-29482-07890-49002-49502-17398-33753-40310
 
##
## ACCEPT LICENSE AGREEMENT
##
## You must agree to the license agreement to install MathWorks products.
## The license agreement can be found in the license_agreement.txt file at the
## root level of the installation DVD.
##
## Example: agreeToLicense=yes
##
## Set agreeToLicense value to yes or no and
## uncomment the line.
 
agreeToLicense=yes
 
##
## SPECIFY OUTPUT LOG
##
## Specify full path of file into which you want the results of the
## installation to be recorded.
##
## Example:
##            (Windows) outputFile=C:\TEMP\mathworks_.log
##            (Linux/macOS) outputFile=/tmp/mathworks_.log
##
## Set the desired value for outputFile and
## uncomment the line.
 
outputFile=/root/matlab_install.log 
 
##
## Enable Login Named User licensing
##
## Set to Yes to enable use of a Login Named User license for all users of this MATLAB installation
## Users must log in to their MathWorks Account when MATLAB starts.
##
## Example: enableLNU=yes
##
## NOTE: This flag is valid in silent installations only.
 
# enableLNU=yes
 
##
## IMPROVE MATLAB
##
## Improve MATLAB by sending user experience information to MathWorks.
## Your participation ensures that you are represented and helps us design
## better products. You can opt in or out of this service either during
## installation or by going to MATLAB preferences.
## https://www.mathworks.com/support/faq/user_experience_information_faq.html
 
improveMATLAB=yes
 
########## Begin: Options for Network License Types #########
##
## SPECIFY PATH TO LICENSE FILE (Required for network license types only)
##
## This value is required when installing as a Network End-User
## Example:
##            (Windows) licensePath=C:\TEMP\license.dat
##            (Linux) licensePath=/tmp/license.dat
## Set the desired value for licensePath and
## uncomment the line.
 
licensePath=/root/network.lic 
 
########## End: Options for Network License Types #########
 
 
################# Begin - Windows Only Options ################
## 
## CHOOSE TO SET FILE ASSOCIATIONS
## 
## Set to true if you want the installer to associate file types used by MathWorks
## products to this version of MATLAB, or false if you do not want the installer to
## associate MathWorks file types with this version of MATLAB.
##
## Default value is true.
##
## Set setFileAssoc value to true or false and
## uncomment the line.
 
# setFileAssoc=true
 
##
## CHOOSE TO CREATE WINDOWS DESKTOP SHORTCUT
##
## Set to true if you would like the installer to create a desktop shortcut icon
## when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is false.
##
## Set desktopShortcut value to true or false and
## uncomment the line.
 
# desktopShortcut=false
 
## CHOOSE TO ADD SHORTCUT TO WINDOWS START MENU
##
## Set to true if you would like the installer to create a Start Menu shortcut
## icon when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is true.
##
## Set startMenuShortcut value to true or false and
## uncomment the line.
 
# startMenuShortcut=true
 
## CREATE a MATLAB Startup Accelerator task
##
## The MATLAB Startup Accelerator installer creates a
## system task to preload MATLAB into the system's cache
## for faster startup.
##
## NOTE: By default, a MATLAB Startup Accelerator task will
## automatically be created.
##
## If you want a MATLAB Startup Accelerator task to be created,
## do not edit this section.
##
## Set createAccelTask value to false if you do not want to
## create an Accelerator task and uncomment the line.
 
# createAccelTask=true
 
################ End - Windows Only Options ################
 
## SPECIFY PRODUCTS YOU WANT TO INSTALL
##
## By default, the installer installs all the products and
## documentation for which you are licensed. Products you are not licensed for
## are not installed, even if they are listed here.
##
## Note:
## 1. To automatically install all your licensed products, do not edit
##    any lines in this section.
## 
## 2. To install a specific product or a subset of products for
##    which you are licensed, uncomment the line for the product(s) you want
##    to install.
 
#product.5G_Toolbox
#product.AUTOSAR_Blockset
#product.Aerospace_Blockset
#product.Aerospace_Toolbox
#product.Antenna_Toolbox
#product.Audio_Toolbox
#product.Automated_Driving_Toolbox
#product.Bioinformatics_Toolbox
#product.Communications_Toolbox
#product.Computer_Vision_Toolbox
#product.Control_System_Toolbox
#product.Curve_Fitting_Toolbox
#product.DDS_Blockset
#product.DO_Qualification_Kit
#product.DSP_System_Toolbox
#product.Data_Acquisition_Toolbox
#product.Database_Toolbox
#product.Datafeed_Toolbox
#product.Deep_Learning_HDL_Toolbox
#product.Deep_Learning_Toolbox
#product.Econometrics_Toolbox
#product.Embedded_Coder
#product.Filter_Design_HDL_Coder
#product.Financial_Instruments_Toolbox
#product.Financial_Toolbox
#product.Fixed-Point_Designer
#product.Fuzzy_Logic_Toolbox
#product.GPU_Coder
#product.Global_Optimization_Toolbox
#product.HDL_Coder
#product.HDL_Verifier
#product.IEC_Certification_Kit
#product.Image_Acquisition_Toolbox
#product.Image_Processing_Toolbox
#product.Instrument_Control_Toolbox
#product.LTE_Toolbox
#product.Lidar_Toolbox
#product.MATLAB
#product.MATLAB_Coder
#product.MATLAB_Compiler
#product.MATLAB_Compiler_SDK
#product.MATLAB_Parallel_Server
#product.MATLAB_Production_Server
#product.MATLAB_Report_Generator
#product.MATLAB_Web_App_Server
#product.Mapping_Toolbox
#product.Mixed-Signal_Blockset
#product.Model_Predictive_Control_Toolbox
#product.Model-Based_Calibration_Toolbox
#product.Motor_Control_Blockset
#product.Navigation_Toolbox
#product.OPC_Toolbox
#product.Optimization_Toolbox
#product.Parallel_Computing_Toolbox
#product.Partial_Differential_Equation_Toolbox
#product.Phased_Array_System_Toolbox
#product.Polyspace_Bug_Finder
#product.Polyspace_Bug_Finder_Server
#product.Polyspace_Code_Prover
#product.Polyspace_Code_Prover_Server
#product.Powertrain_Blockset
#product.Predictive_Maintenance_Toolbox
#product.RF_Blockset
#product.RF_Toolbox
#product.ROS_Toolbox
#product.Radar_Toolbox
#product.Reinforcement_Learning_Toolbox
#product.Risk_Management_Toolbox
#product.Robotics_System_Toolbox
#product.Robust_Control_Toolbox
#product.Satellite_Communications_Toolbox
#product.Sensor_Fusion_and_Tracking_Toolbox
#product.SerDes_Toolbox
#product.Signal_Processing_Toolbox
#product.SimBiology
#product.SimEvents
#product.Simscape
#product.Simscape_Driveline
#product.Simscape_Electrical
#product.Simscape_Fluids
#product.Simscape_Multibody
#product.Simulink
#product.Simulink_3D_Animation
#product.Simulink_Check
#product.Simulink_Code_Inspector
#product.Simulink_Coder
#product.Simulink_Compiler
#product.Simulink_Control_Design
#product.Simulink_Coverage
#product.Simulink_Design_Optimization
#product.Simulink_Design_Verifier
#product.Simulink_Desktop_Real-Time
#product.Simulink_PLC_Coder
#product.Simulink_Real-Time
#product.Simulink_Report_Generator
#product.Simulink_Requirements
#product.Simulink_Test
#product.SoC_Blockset
#product.Spreadsheet_Link
#product.Stateflow
#product.Statistics_and_Machine_Learning_Toolbox
#product.Symbolic_Math_Toolbox
#product.System_Composer
#product.System_Identification_Toolbox
#product.Text_Analytics_Toolbox
#product.UAV_Toolbox
#product.Vehicle_Dynamics_Blockset
#product.Vehicle_Network_Toolbox
#product.Vision_HDL_Toolbox
#product.WLAN_Toolbox
#product.Wavelet_Toolbox
#product.Wireless_HDL_Toolbox

(Dec 13, 2025 07:27:57) Reading from /mnt/matlab_iso/archives
(Dec 13, 2025 07:27:57) Starting local product/component search in download directory
(Dec 13, 2025 07:27:57) Searching for archives...
(Dec 13, 2025 07:27:57) Reading /mnt/matlab_iso/archives
(Dec 13, 2025 07:27:57) Extracting /mnt/matlab_iso/archives/platform_common.zip
(Dec 13, 2025 07:27:57) Extracting /mnt/matlab_iso/archives/platform_glnxa64.zip
(Dec 13, 2025 07:27:57) Archive search complete.  2 total files found.
(Dec 13, 2025 07:28:01) Completed local product/component search
(Dec 13, 2025 07:28:01) Finished reading from/mnt/matlab_iso/archives
(Dec 13, 2025 07:28:01) License file path /root/network.lic
(Dec 13, 2025 07:28:02) Confirm selections
(Dec 13, 2025 07:28:02) Destination
(Dec 13, 2025 07:28:02) /root/Matlab_R2021a/
(Dec 13, 2025 07:28:02) Products
(Dec 13, 2025 07:28:02) 97 of 97 products
(Dec 13, 2025 07:28:02) 23.09 GB required
(Dec 13, 2025 07:28:02) 
(Dec 13, 2025 07:28:02) Download thread pool size = 4
(Dec 13, 2025 07:28:12) Installing Product: MATLAB
(Dec 13, 2025 07:29:44) Installing Product: Simulink
(Dec 13, 2025 07:31:23) Installing Product: 5G Toolbox
(Dec 13, 2025 07:31:24) Installing Product: Aerospace Blockset
(Dec 13, 2025 07:31:26) Installing Product: Aerospace Toolbox
(Dec 13, 2025 07:31:30) Installing Product: Antenna Toolbox
(Dec 13, 2025 07:31:45) Installing Product: Audio Toolbox
(Dec 13, 2025 07:31:54) Installing Product: Automated Driving Toolbox
(Dec 13, 2025 07:32:10) Installing Product: AUTOSAR Blockset
(Dec 13, 2025 07:32:12) Installing Product: Bioinformatics Toolbox
(Dec 13, 2025 07:32:18) Installing Product: Communications Toolbox
➜ ~ 

过一会安装成功以后,启动 matlab,如下所示就是安装成功了

➜ ~ ~/Matlab_R2021a/bin/matlab
MATLAB is selecting SOFTWARE OPENGL rendering.

                                                                                                   < M A T L A B (R) >
                                                                                         Copyright 1984-2021 The MathWorks, Inc.
                                                                                         R2021a (9.10.0.1602886) 64-bit (glnxa64)
                                                                                                    February 17, 2021
To get started, type doc.
For product information, visit www.mathworks.com.
>> 

2. matlab 使用

添加环境变量

首先要添加环境变量,不然会提示 matlab: command not found

  1. vim ~/.bashrc 进入到.bashrc 文件
  2. 在最后加上 export PATH=$PATH:/usr/local/MATLAB/R2021a/bin/
  3. esc+wq 保存退出
  4. source ~/.bashrc 更新 bash
  5. 运行 matlab 命令就不会提示 command not found 啦

命令行运行 matlab 程序

进入到相应文件夹下,比如我们要运行 test.m 文件。运行下面命令之一,直接在命令行输出

matlab -nodesktop -nosplash -r test

matlab -nojvm -nosplash -r test

matlab -nodisplay -r test

试了一下,三种命令均会在命令行进行运行输出,但是第三个命令不会出现弹窗

如果觉得打这么多比较麻烦的话,在 bashrc 文件中添加如下语句 alias mrun='matlab -nodesktop -nosplash -r',然后更新 bashrc 即可

5月 06, 2025
12月 31, 2024
11月 17, 2024