我如何写保护Matlab语言? [英] How can I write-protect the Matlab language?

查看:113
本文介绍了我如何写保护Matlab语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab允许你覆盖内置的函数,而不会有太多的警告。例如,我用变量覆盖了函数 max(),但Matlab没有提示我对此。错误仅在函数调用后才抛出,并且不会帮助您看到实际问题:

  min = 0 ; 
max = 10;
x = linspace(min,max,20);
y = exp(x);
disp(['value is:',num2str(max(y))]]

错误消息:

 下标索引必须是真正的正整数或逻辑。 

有没有办法在启动时或写入时保护所有的Matlab语言一个设置文件,以防止这种情况发生?

解决方案

截至9/2015,我还没有找到一种方法来<保存原生matlab函数/语言,在启动时将其设置为/ flag / etc。



如果您关心某个特定函数,那么有多种方式可以查看它们是否被隐藏,包括Luis Mendo的回答: which('name_of_function','-all')



如果将来发现某种方法,我会很乐意接受该答案!


Matlab allows you to overwrite built in functions without so much as a warning.

For example, I've overwritten the function max() with a variable, but Matlab doesn't alert me to this. An error is only thrown later when the function is called, and doesn't help you see the actual problem:

min     = 0;
max     = 10;
x       = linspace(min,max,20);
y       = exp(x);
disp(['the value is: ', num2str(max(y))])

Error message:

Subscript indices must either be real positive integers or logicals.

Is there a way to write-protect all of the Matlab language at startup, or in a settings file to prevent this?

解决方案

As of 9/2015, I have not found a way to easily write protect native matlab functions/language, as a setting/flag/etc at startup.

If you are concerned about a particular function, there are various ways to see if they are shadowed, including Luis Mendo's answer: which('name_of_function', '-all').

If a method is found in the future, I will gladly accept that answer!

这篇关于我如何写保护Matlab语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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