How do I create a desktop shortcut to start MATLAB with command-line options in MacOS?

4 Ansichten (letzte 30 Tage)
I need to run MATLAB with the command-line option "-cefdisablegpu" on my MacBook. For example, for MATLAB R2022b I run the following commands from Terminal:
cd /Applications/MATLAB_R2022b.app/bin/
./matlab -cefdisablegpu
Is there a way to create a desktop shortcut so that MATLAB starts with this flag automatically when I double-click?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team vor etwa 22 Stunden
Bearbeitet: MathWorks Support Team vor 33 Minuten
To create a desktop shortcut such that MATLAB R20XXx runs with a startup option like "-cefdisablegpu", please follow the steps below. 
  • Open Terminal in your MacBook. 
  • Type the following commands in Terminal:
cd ~/Desktop
touch matlab_new.command
  • Right click the new icon created on the desktop --> Open With --> TextEdit
#!/bin/bash
% chmod u+x /Users/$USER/Desktop/matlab_new.command
cd /Applications/MATLAB_R20XXx.app/bin/
./matlab -cefdisablegpu
chmod u+x /Users/$USER/Desktop/matlab_new.command
  • At this point, you should be able to double-click the created icon on the desktop to start MATLAB with the specified flag. 
  • (Optional) To add a custom icon image, follow the steps in the following Apple discussions thread: https://discussions.apple.com/thread/7720713
  1 Kommentar
Walter Roberson
Walter Roberson am 26 Jan. 2023
Instead of
chmod u+x /Users/username/Desktop/matlab_new.command
with the necessity to replace "username" with your own username, you could instead do
chmod u+x ~/Desktop/matlab_new.command
The ~ in context means "the home directory of the executing account".
The instructions already used ~ in the cd ~/Desktop step so there is no reason to avoid using it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by