局部变量与全局变量(Local variable and Global variable)用 global 就可以把一个变量定义为全局变量。MATLAB 中变量名是区分大小写的,习惯上常将大写字母定为全局变量。
基于14个网页-相关网页
在函数内定义一个与函数可能会用到的全局变量同名的局部变量总是不好的。
It is almost always a bad idea to define a local variable with the same name as a global variable that the function USES or might use.
如果给一个局部变量或函数的参数声明的名字与某个全局变量的名字相同,那么就有效地隐藏了这个全局变量。
If you declare a local variable or function parameter with the same name as a global variable, you effectively hide the global variable.
局部变量可以与全局变量具有相同的名称,但它们是完全不同且相互分离的。
A local variable can have the same name as a global variable, but it is entirely distinct and separate.
应用推荐