vs code 运行matlab代码


title: vs code 运行 matlab 代码
tags: vs code
category: matlab

参考

https://blog.csdn.net/weixin_42815609/article/details/103830253

安装插件

在 vs code 中安装如下插件

Code Runner、Matlab、matlab-formatter

打开配置文件

在配置文件中添加如下代码

"matlab.mlintpath": "D:\\xuexiruanjian\\matlab2020b\\bin\\win64\\mlint.exe",    // 此处路径按需要修改
"matlab.matlabpath": "D:\\xuexiruanjian\\matlab2020b\\bin\\matlab.exe",         // 此处路径按需要修改
"matlab.linterEncoding": "gb2312",
"code-runner.executorMap":{
    "matlab": "cd $dir && matlab -nosplash -nodesktop -r $fileNameWithoutExt",
},
"files.associations": {
    "*.m": "matlab",
},
"[matlab]" : {
    "files.encoding": "gb2312",
},
"files.autoGuessEncoding": true

添加系统变量

搜索 “编辑系统环境变量”,在弹出的窗口中选择 “环境变量”,然后双击 “系统变量” 中的 “path” 变量,然后添加如下路径

需要按情况修改

D:\xuexiruanjian\matlab2020b\bin

运行程序

以 vs code 打开 .m 文件,然后在窗口中 右键,然后选择 “run code”,等待片刻即可运行

posted @ 2022-05-28 00:13  tiansz  阅读(285)  评论(0编辑  收藏  举报