Referring to the official documentation of “Start MATLAB program from macOS Terminal” https://ww2.mathworks.cn/help/matlab/ref/matlabmacos.html?lang=en
mkdir newFolder && cd newFolder
code .
mkdir .vscode && cd .vscode
touch settings.json && vim settings.json
{
"code-runner.executorMap": {
"matlab": "/Applications/MATLAB_R2020b.app/bin/matlab -sd $dir -batch $fileNameWithoutExt",
},
"code-runner.clearPreviousOutput": true,
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.saveFileBeforeRun": true,
"code-runner.showExecutionMessage": true,
"code-runner.runInTerminal": true,
"code-runner.preserveFocus": true,
"code-runner.ignoreSelection": true,
}
Then use the extension Code Runner to run MATLAB script in VS Code .
|