在重载内置函数时避免MATLAB启动警告吗? [英] Avoid MATLAB startup warning when overloading buildin functions?

查看:153
本文介绍了在重载内置函数时避免MATLAB启动警告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处所述,我创建了我自己的figure.m,它很好地重载了内置的figure命令.现在,每当我启动MATLAB时,我都会收到警告

As described here, I created my own figure.m which nicely overloads the built-in figure command. Now, whenever I start MATLAB I get the warning

警告:函数C:\ somepath \ figure.m具有 与MATLAB内置名称相同.我们 建议您将功能重命名为 避免潜在的名称冲突.

Warning: Function C:\somepath\figure.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.

考虑到我的期望行为,是否有任何方法可以停用此警告?

Is there any way to deactivate this warning, given that it is desired behavior in my case?

您可能会说我应该以不同的方式调用函数而不是重载,但是对于我的开发系统,我确实认为这种重载是正确的方法...

You might say that I should call my function differently instead of overloading, but I do feel for my development system this overloading is the right way to go...

更新

如Aabaz所述,您可以使用

As mentioned by Aabaz you can globally turn off this warning using

warning off MATLAB:dispatcher:nameConflict

,需要在matlabrc.m的开头(在设置路径之前).但是,我仍然对一个解决方案感兴趣,该解决方案可以专门删除此错误消息,以使fig.m(或某些自定义函数列表)过载,而不是针对所有函数.我想我在这里问的太多了;-)?

which needs to go at the beginning of matlabrc.m (before the path is set). However, I would still be interested in a solution which could specificially remove this error message for overloading figure.m (or some self-defined list of functions) instead of for all functions. I guess I'm asking a bit too much here ;-) ?

推荐答案

我似乎无法在Matlab版本(R2008b)中复制此警告,但无论如何,如果您还没有尝试过,则应该查看函数 lastwarn

I cannot seem to replicate this warning with my Matlab version (R2008b) but anyway If you did not already try it you should look into the functions lastwarn and warning that allow you to identify and turn off this warning.

PS:警告最终由于某种原因而出现,我能够使用lastwarn和警告将其关闭.

PS: the warning eventually came for some reason and I was able to use lastwarn and warning to turn it off.

>>[msgstr msgid]=lastwarn;
>>disp(msgid);
MATLAB:dispatcher:nameConflict
>>warning('off',msgid);

我应该补充一点,您应该在启动上将其关闭这样才能在Matlab的不同会话之间有效.

I should add that you should turn it off at startup for this to be effective between different sessions of Matlab.

这篇关于在重载内置函数时避免MATLAB启动警告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆