Can I change the prompt in MATLAB?

巧了我就是萌 提交于 2019-12-01 03:19:26

There is a submission on the MathWorks File Exchange that can do this for you: setPrompt by Yair Altman. Using it in R2010b, I noticed that I was getting the warning message:

Warning: Possible deprecated use of set on a Java callback. 
> In setPrompt at 115

Which I was able to suppress using the warning function like so:

warning('off','MATLAB:hg:JavaSetHGProperty');

And here's how I changed the prompt to the host name using the system function:

>> [~,systemString] = system('hostname');
>> setPrompt([deblank(systemString) '>> ']);
P11-4504>>

The function deblank is used to remove trailing whitespace (in this case a newline) from the string.

NOTE: The above changes (suppressed warning and modified prompt) don't persist after you quit and restart MATLAB, so you could put the above code in your startup.m file to apply them automatically every time you start a new session.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!