【问题标题】:How do I specify the MATLAB editor keybindings programmatically如何以编程方式指定 MATLAB 编辑器键绑定
【发布时间】:2016-07-04 16:13:17
【问题描述】:

我想将键盘键绑定设置为 Windows 默认设置,我想在启动时使用startup.m 执行此操作,因为我希望在大量系统上设置此设置。

首选项对话框中的等效设置是:MATLAB > Keyboard > Shortcuts > Active Settings: Windows Default Set.

Suever回答后startup.m的提议

见第 8 行

% TODO set startup script in $HOME/Documents/bin/matlab/startup.m in Terminal

% all commands here will be run at startup etc startup.m
% TODO set user path as relative by $HOME/Documents/bin/matlab/
%userpath('/home/masi/Documents/bin/matlab/')
% TODO How to set up userpath outside this Matlab script in Terminal?

% http://stackoverflow.com/a/38188945/54964
if ( not( com.mathworks.services.Prefs.getStringPref('CurrentKeyBindingSet') == 'Windows' ) )
        com.mathworks.services.Prefs.setStringPref('CurrentKeyBindingSet', 'WindowsDefaultSet.xml')
end

% Event errors else with touchpad scroll
!synclient HorizTwoFingerScroll=0

Matlab:2016a
系统:Linux Ubuntu 16.04

【问题讨论】:

    标签: matlab scripting


    【解决方案1】:

    如果您想以编程方式执行此操作,您可以使用 undocumented 函数来设置首选项。

    com.mathworks.services.Prefs.setStringPref('CurrentKeyBindingSet', 'Windows')
    

    如果您想要不同的键绑定,您可以从首选项对话框中显式设置值,然后调用以下命令来检索该值。

    com.mathworks.services.Prefs.getStringPref('CurrentKeyBindingSet')
    

    这个命令应该只需要在每个 MATLAB 安装中运行一次,因此将它放在 startup.m 文件中可能是多余的,并且还会阻止用户更改您的默认设置。

    【讨论】:

    • @Masi MATLAB 将自动运行startup.m,如果它位于userpath 或当前工作目录中。
    • @Masi 什么? userpath 只是默认的用户文件夹。 mathworks.com/help/matlab/ref/userpath.html
    • @Masi 它不需要图形用户界面....您也只需要在每个系统中运行上述命令一次,因此它实际上并不需要在startup.m
    • 同样在startup.m 中设置userpath 确实没有效果,因为MATLAB 已经在userpath 中查找该文件。无论如何,这完全是另一个问题。这个问题似乎已经解决了。
    • @Masi 对,但不管它是什么,总是设置它可能更容易,因为如果它不同,你无论如何都会改变它
    猜你喜欢
    • 2021-06-18
    • 2012-12-03
    • 2011-10-22
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 2012-01-30
    • 1970-01-01
    • 2015-10-20
    相关资源
    最近更新 更多