Is there a way to set key bindings for a custom script in MATLAB?

I use several custom shortcuts on a regular basis (for workspace cleanup and breakpoint loading and saving, for example) and would like to specify keyboard shortcuts for them, which is essentially specifying shortcuts for scripts. Is this possible?

EDIT 1: I found this, but it is rather old, and provides a partial solution only. I have not yet tried it.

EDIT 2: This MATLAB blog entry has this question in the comments (#28) with no answer. A similar question appears in the comments of a different entry about keyboard shortcuts (#23), again with no answer.

有帮助吗?

解决方案

On Windows, any button on the quick-access toolbar is automatically assigned a keyboard shortcut of the form Alt+1, Alt+2, Alt+3 etc., so if you place your script in a shortcut on the toolbar, it will have this associated keyboard shortcut, which can be viewed by pressing Alt.

This does not allow you to customize the key binding (besides the number, which is simply the button's location on the toolbar, from left to right), but it does provide for a handy way to run custom scripts with a simple keyboard shortcut.

Note also that any custom shortcut can also be accessed by pressing Alt+S and then the shortcut number as it appears in the shortcuts tab.

I am yet to find a solution for MATLAB on macOS.

其他提示

As it seems that Matlab does not provide this functionality internally, you might try to use a shortcut at the desktop level. Matlab has a command line interface, and also accepts statements to evaluate as a command line argument. See here: http://www.mathworks.de/de/help/matlab/ref/matlabwindows.html http://www.mathworks.de/de/help/matlab/ref/matlabunix.html

The command line option I am referring to is -r.

I did not try this, it might very well be that the statement is not executed in the running session so it is not helpful for cleaning the workspace.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top