是否可以设置Matlab在运行之前验证可访问的功能 [英] Is it possible to set matlab to validate reachable functions before running

查看:69
本文介绍了是否可以设置Matlab在运行之前验证可访问的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯于使用强类型化的编译语言,因此我习惯于拼写错误,因为它们几乎立即被当作未声明的变量.

I am used to strongly typed, compiled languages so I'm used to misspellings being pretty much instantly picked up as undeclared variables.

但是,由于Matlab是弱类型语言,因此它不会自动发生,而我的开发周期往往是:

However since Matlab is a weakly typed language this doesn't happen automatically and my development cycle tends to be:

write function(s)
|
˅
Run  <-------------------------
|                             |
˅                             |
Crash due to misspelling/typo |
|                             |
˅                             |
Correct typo -----------------|

运行过程可能要花几分钟才能到达错字,这大大减慢了我的开发周期.
我正在使用Matlab版本2007b

The run process can run for several minutes before getting to the typo, which slows down my development cycle considerably.
I'm using matlab version 2007b

是否有任何方法可以验证功能,从而无需运行整个程序就可以使用不存在的变量等?鉴于每个函数都有其自己的可变空间,因此感觉应该可行.

Is there any way to validate a function such that the use of non-existent variables etc are picked up without having to run the whole program? Given that each function has its own variable space it feels like this should be possible.

我知道可以使用 depfun ,但是我无法找到任何方法来验证那些功能.

I am aware that is it possible to get a list of dependencies using depfun however I've not been able to find any way to validate those functions.

例如,以下功能将始终失败,但在运行之前不会产生警告

For example the following function will always fail but produces no warnings until it is run

function [biggest]=getBiggest(variableName1, variableName2)
    if variablename1>variableName2, %<---misspelling!
        biggest=variableName1;
    else
        biggest=variableName2;
    end
end

推荐答案

我怀疑您正在使用其他编辑器,或者您更改了警告首选项.

I suspect that you are either using a different editor, or that you changed your warning preferences.

转到home > preferences > code analyzer时,请确保已启用包含以下内容的内容:

When going to home > preferences > code analyzer make sure you have the one enabled that contains something like:

无法确定...是变量还是函数

cannot determine whether ... is a variable or a function

这篇关于是否可以设置Matlab在运行之前验证可访问的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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